Multiple Zend_Auth Instances

I want to create multiple instances of the Zend_Auth class, as I have two modules

  • Administrator
  • Front

What happens when I log in to Admin, it automatically logs into Front or vice versa.

I want to work in both modules separately after simultaneous authentication.

+4
source share
1 answer

Zend_Auth is a singleton, so you cannot. I use Zend_Acl to provide access to admin items only to users with the admin role.

To create a second Auth object, in principle you can get Zend_Auth in App_Auth and use a different session namespace. I have never tried this, but my starting code would look like this:

 class App_Auth { /** * Returns the persistent storage handler * * Session storage is used by default unless a different storage adapter has been set. * * @return Zend_Auth_Storage_Interface */ public function getStorage() { if (null === $this->_storage) { /** * @see Zend_Auth_Storage_Session */ require_once 'Zend/Auth/Storage/Session.php'; $this->setStorage(new Zend_Auth_Storage_Session('App_Auth')); } return $this->_storage; } } 

You might need to override more.

+3
source

Source: https://habr.com/ru/post/1307224/


All Articles