array('allow', //allow only Admin users to create/delete records
'actions'=>array('create', 'delete'),
'expression'=>Yii::app()->user->role=='Admin',
),
This works OK, however when I access the page after a long period of inactivity, I get the following error message:
Property "CWebUser.role" is not defined.
I think this may be to do with the session data expiring. How can I fix this / is there a better way of doing this?
class UserIdentity extends CUserIdentity
{
private $_id;
public function authenticate()
{
$this->_id=$record->id;
}
public function getId()
{
return $this->_id;
}
}
So in the above code, the id is not stored in the session and I can access it by Yii::app()->user->id
Can I do something similar to store the ‘role’ as a variable, but not in the session?
class UserIdentity extends CUserIdentity
{
private $_id;
private $_role;
public function authenticate()
{
$this->_id=$record->id;
$this->_role=$you_role;
}
public function getId()
{
return $this->_id;
}
public function getRole()
{
return $this->_role;
}
}
Do you have any idea why Yii::app()->user->role didn’t work? I’m using version 1.0.10. Could there be a config issue somewhere, my colleague says it should have worked…
No I mean when a user is logged in, if they navigate to /index.php?r=site/login the login form is displayed, even though they are still logged in! I think it should redirect user to the home page or something.