logo       

Re: Using Zend_Auth to retrieve a user's role to use in Zend_Acl: msg#00019

php.zend.framework.auth

Subject: Re: Using Zend_Auth to retrieve a user's role to use in Zend_Acl



On 03/10/2007, Nathan Wright <thatnateguy-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx> wrote:
Subclassing the adapter isn't necessary. You should be able to do this instead:

if (Zend_Auth::getInstance()->hasIdentity()) {
$role = Zend_Auth::getInstance()->getIdentity()->role;
}

Nathan,

I wasn't able to do that, because Zend_Auth::getInstance()->getIdentity() returns a string, not an object.

 

See these two tutorials on auth & acls respectively. I found them far more helpful than the one on the zend devzone.



Cheers,
ncw



On 03/10/2007, David Mintz < david-dMffkYQFJ3MKxoK4Ny/0iQ@xxxxxxxxxxxxxxxx> wrote:


Delighted to be of service!  I don't see any reason why your implementation of authenticate() can't do your storage work for you upon successful authentication.

Of course, I was being extremely stupid. Instead of returning:

new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $this->_username);

I also could've returned

new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $user); // Where $user is an array including the role and username

Problem solved!

--
Vincent
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise