JayRoe
(Jakobrosenberg)
June 21, 2010, 3:26pm
1
'authManager'=>array(
'class'=>'CDbAuthManager',
'defaultRoles'=>array('guest'),
'connectionID'=>'db',
That is my default role and for some reason it remains the active role, even after logging in. When I log in as superadmin with all operations and child roles assigned to my account, Yii::app()->user->checkAccess() only returns true for operations that are assigned to guests.
zaccaria
(Matteo Falsitta)
June 21, 2010, 6:31pm
2
Did you assigned the role to your superadmin?
Yii::app()->authManager->assign('aminUser', 'adminRole');
JayRoe
(Jakobrosenberg)
June 21, 2010, 7:53pm
3
zaccaria:
Did you assigned the role to your superadmin?
Yii::app()->authManager->assign('aminUser', 'adminRole');
Yes, print_r(Yii::app()->authManager->getRoles(1)); returns a CAuthItem Object called superadmin. "1" is my user id.
JayRoe
(Jakobrosenberg)
June 22, 2010, 8:59am
4
I have found the problem. For some reason Yii::app->user->getId() returns the name rather than the unique key of the member.
coma
(Amtxxx)
October 12, 2010, 7:29am
5
Hi, did you find a way to resolve the problem? I’m having the same issue… getId returns the name and checkAccess doesn’t work…
coma
(Amtxxx)
October 12, 2010, 9:11am
6
found it forgot to override the getId method in UserIdentity class to return $_id
rahulraj
(Rahul)
February 10, 2011, 2:58pm
7
could you please help me. let me know this is correct or not
private $_id;
/**
* Authenticates a user using the User data model.
* @return boolean whether authentication succeeds.
*/
public function authenticate()
{
$user=User::model()->findByAttributes(array('username'=>$this->username));
if($user===null)
{
$this->errorCode=self::ERROR_USERNAME_INVALID;
}
else
{
if($user->password!==$user->encrypt($this->password))
{
$this->errorCode=self::ERROR_PASSWORD_INVALID;
}
else
{
$this->_id = $user->id;
if(null===$user->last_login_time)
{
$lastLogin = time();
}
else
{
$lastLogin = strtotime($user->last_login_time);
}
$this->setState('lastLoginTime', $lastLogin); $this->errorCode=self::ERROR_NONE;
}
}
return !$this->errorCode;
}
public function getId()
{
return $this->_id;
}