1

i'm getting crazy with my authentication data.

When my in my app someone logs in, my authcontroller stores the user data in the Zend_Auth storage

class AuthController extends Zend_Controller_Action
{ ...
   public function loginAction()
   { ...
      $userMapper = new Application_Model_UsersMapper();
      $user = $userMapper->fetchById($adapter->getResultRowObject()->id);
      $this->auth->getStorage()->write($user);
   }
}

After this, I created a plugin to add user permitions (that are stored in the User object returned by the $userMapper) to my Acl System.

The problem is that when I call Zend_Auth->getInstance()->getIdentity(), I find only the username instead of the entire Object !

Stoyan Dimov
  • 5,250
  • 2
  • 28
  • 44
russanto
  • 21
  • 1
  • 3
  • what does var_dump for $user return? Code seems all right. How are you adding user permissions, please add code to it. – ro ko Mar 17 '13 at 04:11

2 Answers2

1

I have solved my problem ! There was an error in mysql configuration. read() function, not finding anything in the Storage, returned username. Thank you for helping me.

russanto
  • 21
  • 1
  • 3
0

This is because the Identity is actually the username (in your case). If you want to get the entire object you can get it like this:

$user = $this->auth->getStorage()->read();

Another thing to consider is that the default storage for Zend_Auth is a session so you might need to serialize the object if it is attached to some other resources like db etc.

Hope this helps :)

Stoyan Dimov
  • 5,250
  • 2
  • 28
  • 44
  • 1
    Nothing to do; I have replaced $this->auth->getIdentity() with $this->auth->getStorage()->read() but the result is always the same. The strangest thing is that I've just copied all the code on my server on localhost and it works fine ! – russanto Mar 16 '13 at 23:05