Hi,
I can’t set using setState function in useridentity,
My Useridentity Page,
<?php
/**
-
LoginForm class.
-
LoginForm is the data structure for keeping
-
user login form data. It is used by the ‘login’ action of ‘SiteController’.
*/
class UserIdentity extends CUserIdentity
{
/**
* Authenticates a user.
* The example implementation makes sure if the username and password
* are both 'demo'.
* In practical applications, this should be changed to authenticate
* against some persistent user identity storage (e.g. database).
* @return boolean whether authentication succeeds.
*/
public function authenticate()
{
$member=$this->member;
if($member=="admin")
{
$record = TblAdmin::model()->findByAttributes(array('username'=>$this->username, 'password'=>$this->password));
}
else if($member=="reseller")
{
$record = Reseller::model()->findByAttributes(array('user_name'=>$this->username, 'password'=>$this->password,'status'=>'Active'));
}
if (is_null($record))
{
$this->errorCode = self::ERROR_PASSWORD_INVALID;
}
else
{
$this->errorCode = self::ERROR_NONE;
$this->setState('role', $this->member);
if($member=="admin")
{
$this->setState('id', $record->adminid);
$this->setState('name', $record->username);
}
else if($member=="reseller") {
$this->setState('id', $record->id);
$this->setState('name', $record->user_name);
}
}
if ($this->errorCode)
{
Yii::app()->user->setFlash('login_message', 'Please confirm your login ID and password.');
}
else
{
Yii::app()->user->setFlash('login_message', 'Logged in.');
}
return !$this->errorCode;
}
}
What wrong in my code?plz give my solution, cant get value Yii::app()->user->getState(‘role’);