Revision #5 has been created by Antonio Ramirez on May 13, 2011, 5:42:37 AM with the memo:
Fixed minor code variation
« previous (#4) next (#6) »
Changes
Title
unchanged
Implementing a User Level Access System
Category
unchanged
Tutorials
Yii version
unchanged
Tags
unchanged
tutorial, Authentication, tips
Content
changed
[...]
$user = $this->loadUser();
if ($user)
return $user->level==LevelLookUp::ADMIN;
return false;
}
// saving logged users into a state
protected function afterLogin()
{
$this->setState('___uid', $this->id);
return true;
}
// Load user model.
protected function loadUser()
{
if ( $this->_model === null ) {
$this->_model = User::model()->findByPk( $this->
getState('___uid')id );
}
return $this->_model;
}
}
```[...]