Bonjour,
Thanks to everyone for making my experience with Yii an enjoyable one.
Now check this out.
I was successfully able to add information to Yii::app()->user using this page.
http://www.yiiframework.com/wiki/60/add-information-to-yii-app-user-by-extending-cwebuser/
Now I have implemented mine in this manner
<?php
/**
* UserIdentity represents the data needed to identity a user.
* It contains the authentication method that checks if the provided
* data can identity the user.
*/
class UserIdentity extends CUserIdentity
{
private $_id;
public function authenticate()
{
$username=strtolower($this->username);
$user=User::model()->find('LOWER(username)=?',array($username));
if($user===null)
$this->errorCode=self::ERROR_USERNAME_INVALID;
else if(!$user->validatePassword($this->password))
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else
{
$this->_id=$user->id;
$this->username=$user->username;
$this->setState("user_rank",$user->user_rank);
$this->errorCode=self::ERROR_NONE;
}
return $this->errorCode==self::ERROR_NONE;
}
public function getId()
{
return $this->_id;
}
}
Unfortunately I get the error
" CException;Property "CWebUser.user_rank" is not defined" when the session /state is lost
How do I go around this problem to maybe at worst send the user to the login page or at best continue to save the state
Merci beaucoup