2010年8月9日星期一

Re: [fw-auth] Anything that might change my identity stored in Zend_Auth/Session?

I would check to see what is going on inside your __sleep & __wakeup
methods for your Application\Model\User object. It seems like when it
goes through session serialization&unserialization, the state of the
object is not being returned back to "normal".

Also, if you are using session files, hvae a look in the files to see if
the data you'd expect to be in there for your session looks correct.

-ralph

jiewmeng wrote:
> i am using doctrine 2 with Zend Framework 1.10. i stored my whole
> doctrine (entity) user object in Zend_Session (default using
> Zend_Auth::authenticate()),
>
> |// in my Auth Adapter
> ...
> $em = Zend_Registry::get('em');
> $query = $em->createQuery('select u from Application\Models\User u WHERE u.name = :username')
> ->setParameter('username', $this->username);
> $user = $query->getSingleResult();
>
> // login success ...
> return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $user);|
>
> if b4 the return, i try to do
>
> |$user->id // returns 1 (correct)
> $em->contains($user); // true|
>
> if i try the same in a method elsewhere (in this case my posts model class)
>
> |$user = Zend_Auth::getInstance()->getIdentity();
> $em->contains($user); // returns false
> $user->name // returns correctly ...
> $user->id // is null/empty|
>
> so the things that changed is that id is null, and it seems
> unmanaged/detached by doctrine
>
>
> ------------------------------------------------------------------------
> View this message in context: Anything that might change my identity
> stored in Zend_Auth/Session?
> <http://zend-framework-community.634137.n4.nabble.com/Anything-that-might-change-my-identity-stored-in-Zend-Auth-Session-tp2316993p2316993.html>
> Sent from the Zend Auth mailing list archive
> <http://zend-framework-community.634137.n4.nabble.com/Zend-Auth-f676055.html>
> at Nabble.com.

没有评论: