Zend_Auth: Allow user to be logged in to multiple tables/identities

前端 未结 4 1540
时光说笑
时光说笑 2021-02-06 02:23

I am using Zend_Auth for authentication in a web portal.

A normal mySQL \"users\" table with a login and password column gets quer

4条回答
  •  感情败类
    2021-02-06 03:15

    Because Zend_Auth is a singleton, creating custom auth adapters for each authentication source only solves the first half of this issue. The second half of the issue is that you want to be able to log in simultaneously with multiple accounts: one of each authentication source.

    I asked a similar question recently. The solution was to extend Zend_Auth as shown in the accepted answer. I then initialize the different authentication types in my bootstrap.

    protected function _initAuth()
    {
        Zend_Registry::set('auth1', new My_Auth('auth1'));
        Zend_Registry::set('auth2', new My_Auth('auth2'));
        Zend_Registry::set('auth3', new My_Auth('auth3'));
    }
    

    So, instead of the singleton Zend_Auth::getInstance() you would use Zend_Registry::get('auth1'), etc.

提交回复
热议问题