hay guys, i have problem with CWebuser role in my app. I have Admin module, i want if i login (#set role) i can be affect role to other module.
For example :
i login in admin module (if success set role).
i get Yii::app()->user->role from other module. That’s possible ??
my useridentity
class UserIdentity extends CUserIdentity {
private $_id;
/**
* 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() {
$record = LOGIN::model()->findByAttributes(array('USER' => $this->username));
if (is_null($record)) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
} else if ($record->PASSWORD != $this->password) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
$this->errorCode = self::ERROR_USERNAME_INVALID;
} else {
$this->_id = base64_encode($record->ID_LOGIN);
switch ($record->HAK_AKSES) {
case 0: $role = 'Administrator';
break;
case 1: $role = 'Majelis Tinggi';
break;
case 2: $role = 'Assesor';
break;
case 3: $role = 'Pengusul';
break;
case 4: $role = 'Tamu';
break;
default:
$role = '';
}
$this->setState('role', $role);
//$this->setState('nome', $record->nome);
$this->errorCode = self::ERROR_NONE;
}
return!$this->errorCode;
}
public function getId() {
return $this->_id;
}
}