开发者

Multiple instances of Zend_Auth

开发者 https://www.devze.com 2022-12-27 18:40 出处:网络
I want to create multiple instances of Zend_Auth class as I have two modules Admin Front What\'s happening is when I login into Admin, it automatically get logged into

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

  • Admin
  • Front

What's happening is when I login into Admin, it automatically get logged into Front or vice-versa.

What I want is to wo开发者_JS百科rk in both modules separately after simultaneous authentication.


Zend_Auth is a singleton, so you can't. What I do is to use Zend_Acl ensure that only users with a role of "admin" can get at the administration stuff.

To create a second Auth object, in principle, you could derive Zend_Auth to App_Auth and use a different session namespace. I've 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;
    }
}

It's possible that you have to override more.

0

精彩评论

暂无评论...
验证码 换一张
取 消