Thank you for clarifying ! 

Darby Felton wrote:
> 
> Hi,
> 
> The getIdentity() method is documented to return a mixed value - it
> could be an integer (e.g., primary key value) or a string (e.g.,
> username) or some kind of object (e.g., table row data). The DbTable
> authentication adapter returns an instance of stdClass that represents
> the table row data.
> 
> I think that the problem we see here is that you are passing an object,
> rather than a string, to the logger. If you want to pass the username,
> then:
> 
> $logger->debug($auth->getIdentity());
> 
> should instead be more like:
> 
> $logger->debug($auth->getIdentity()->username);
> 
> Best regards,
> Darby
> 
> debussy007 wrote:
>> Hello,
>> 
>> When I try to print the identity :
>> $auth = Zend_Auth::getInstance();
>> $logger->debug($auth->hasIdentity());  // prints 1
>> $logger->debug($auth->getIdentity());  // prints exception
>> 
>> I have the following exception :
>> Catchable fatal error: Object of class stdClass could not be converted to
>> string in D:\websites\mysite\library\Zend\Log\Formatter\Simple.php on
>> line
>> 70
>> 
>> Though, I think it should returns me the username.
>> 
>> This is my auth code:
>> 
>> // in bootstrap
>> [...]
>> $authAdapter = new MyZend_Auth_Adapter_DbTable($dbAdapter);
>> $authAdapter->setTableName('members')
>>             ->setIdentityColumn('username')
>>             ->setCredentialColumn('password')
>>             ->setCodeColumn('code');
>> Zend_Registry::set('authAdapter', $authAdapter);
>> [...]
>> 
>> // in authController
>> [...]
>> $result = $authAdapter->authenticate();
>> [...]
>> case MyZend_Auth_Result::SUCCESS:
>>      $omit = array(
>>              'id_member',
>>              'password',
>>              'email',
>>              'date_of_birth',
>>              'country',
>>              'code',
>>              'valid_code'
>>      );
>>      $data = $authAdapter->getResultRowObject(null, $omit);
>>      
>>      $logger->debug(print_r($data, true));
>>      /* PRINTS :
>>      2007-09-20T12:19:22+02:00 DEBUG (7): stdClass Object
>>      (
>>          [username] => mathi
>>      )
>>      */
>>      
>>      $auth = Zend_Auth::getInstance();
>>      $auth->getStorage()->write($data);
>>      $logger->debug($auth->hasIdentity());
>>      $logger->debug($auth->getIdentity());  // <- EXCEPTION
>>      
>>      break;
>> [...]
>> 
>> Thank you.
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Zend_Auth-%3A-getIdentity-issue-tf4486708s16154.html#a12804531
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to