Authenticate Admin In Useridentify

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()






        else if(!$user->validatePassword($this->password))







            $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?


The wiki page is exactly what you need.

just take a look at rbac :

if you set ‘isAdmin’=1 to the admin user, then access control will be needed before admin actions. That is:

if (Yii::app()->user->isAdmin===1)

  //do some admin actions.


  //throw a HttpException to promote that the user is not allowed to do this action.