Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [ZendFramework]Auth Acl krok po kroku, stack
trylas
post
Post #1





Grupa: Zarejestrowani
Postów: 53
Pomógł: 1
Dołączył: 7.09.2008

Ostrzeżenie: (0%)
-----


Hejho,
probuje stworzyc system logowania z podzialem na role i zasoby. Jednak utknalem na jakims banalnym bledzie i nie moge dojsc gdzie jest szkopul.

acl.php
  1. <?php
  2. class Acl
  3. {
  4. public function __construct()
  5. {
  6. $this->acl = new Zend_Acl();
  7.  
  8. $this->acl->addRole(new Zend_Acl_Role('guest'));
  9. $this->acl->addRole(new Zend_Acl_Role('user'));
  10. $this->acl->addRole(new Zend_Acl_Role('admin'));
  11.  
  12. $this->acl->add(new Zend_Acl_Resource('admin'));
  13. $this->acl->add(new Zend_Acl_Resource('index'));
  14. $this->acl->add(new Zend_Acl_Resource('user'));
  15.  
  16. $this->acl->allow('guest','user','login');
  17. $this->acl->allow('guest','user','logout');
  18. $this->acl->allow('guest','index','index');
  19. $this->acl->deny('guest','admin');
  20. $this->acl->allow('admin');
  21. }
  22. }

accessCheck.php
  1. <?php
  2. class App_Plugin_AccessCheck extends Zend_Controller_Plugin_Abstract
  3. {
  4. public function preDispatch( Zend_Controller_Request_Abstract $request )
  5. {
  6. if(!Zend_Auth::getInstance()->hasIdentity())
  7. {
  8. $role = 'guest';
  9. echo $role;
  10. }
  11. else
  12. {
  13. $auth = Zend_Auth::getInstance();
  14. $identity = $auth->getIdentity()->role;
  15. $role = $identity;
  16. echo $role;
  17. }
  18. $resource = $request->getControllerName();
  19. $action = $request->getActionName();
  20.  
  21. $acl = new Model_Acl();
  22.  
  23. if(!$acl->isAllowed($role,$resource,$action)){
  24. Zend_Debug::dump($role);
  25. Zend_Debug::dump($resource);
  26. Zend_Debug::dump($action);
  27. $request->setControllerName('Error');
  28. $request->setActionName('priviliges');
  29.  
  30. }
  31. }
  32. }

problem polega na tym ze w nie mozna sie zalogowac bo zrzuca na Controller Error i Action Priviliges
Go to the top of the page
+Quote Post
seth-kk
post
Post #2





Grupa: Zarejestrowani
Postów: 444
Pomógł: 79
Dołączył: 26.05.2009

Ostrzeżenie: (0%)
-----


Zend_Acl przypisujesz do wlasnosci obiektu Acl a nastepnie szukasz go w samym obiekcie (zamiast w tej wlasnosci)


--------------------
Go to the top of the page
+Quote Post
trylas
post
Post #3





Grupa: Zarejestrowani
Postów: 53
Pomógł: 1
Dołączył: 7.09.2008

Ostrzeżenie: (0%)
-----


oki wszystko smiga znalazlem babole. thnx
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 10:49