Search code examples
zend-frameworktwitterzend-auth

How to tell zend_auth which user is logged in


I'm struggling with something that should be really easy I think. I have a authentication system on my page built with zend_auth. It all works flawlessly, but now I wanted to give users the opportunity to log in with twitter.

I've been able to build the whole oauth authentication process, and after a successful twitter authentication I can get the twitter username from twitter. After that, I do a lookup in my user table, and find the user with that twitter name (I have a column for it in my database).

Now I have the user_id of the logged in user, but how do I get zend_auth to know that that user is logged in? I have a role based rights system stored in the database, so the zend_auth_storage needs to know the ID of the logged in user.


Solution

  • You have to write the user row in the storage yourself .

    Zend_Auth::getInstance()->getStorage()->write($userRow);
    

    $userRow can be different in your case its basically the data which get stored in session once user gets logged in generally its a single row in users table (minus the password column for security reasons)