I just installed Yii and a new webapp and I did read a lot of tutorial stuff. I also made some nice changes especially in the views.
But now I need your help:
How can I set an user as an admin when I use my own authenticate method?
I removed the normal code with fixed access data of two users.
public function authenticate()
{
$username=strtolower($this->username);
$user=User::model()->find('LOWER(benutzername)=?',array($username));
if($user===null)
$this->errorCode=self::ERROR_USERNAME_INVALID;
else if(!$user->validatePassword($this->password))
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else
{
$this->_id=$user->id;
$this->username=$user->benutzername;
$this->errorCode=self::ERROR_NONE;
$this->setState("isAdmin", 1);
}
return $this->errorCode==self::ERROR_NONE;
}
For testing, I would see every user as admin. But this is not working. I can’t, as an logged in user, edit and view things the admin can.
Isn’t the setState(“isAdmin”) right?
Regards