Reputation: 803
I tried to install yii extension for one of my application. I am getting error of "Error 403 You are not authorized to perform this action.
" however from what i see in the database, the tables are created "authassignment","authitem","authitemchild","rights".
And under "authassignment" i have data
Admin 1 NULL N;
where 1 is my userid. This is correct as for my "user" table i have one account. The structure is
CREATE TABLE IF NOT EXISTS `user` (
`user_id` int(10) AUTO_INCREMENT NOT NULL,
`login_id` varchar(255) NOT NULL,
`login_name` varchar(255) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`level` int(3) NOT NULL DEFAULT '1',
PRIMARY KEY (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
i have then modified "config/main.php" to reflect the changes
'rights'=>array(
'install'=>false,
'superuserName'=>'Admin',
'userIdColumn'=>'user_id',
'userNameColumn'=>'login_id',
),
After numerous research, i think above steps are correct. However when i try to access /rights
after installation. i face the problem again:
**Error 403 You are not authorized to perform this action**.
This is weird. I checked with installation document, there is nowhere mentioning this problem. So i guess that maybe because the way of login is wrong??
public function authenticate()
{
$array=$this->auth_array;
$criteria=new CDbCriteria;
$criteria->compare('email',$array['email']);
$u=User::model()->findAll($criteria);
if(count($u)==0)
{
$user = new User;
$user->email = $array['email'];
$user->login_name=$array['name'];
$user->login_id=$array['login_id'];
if($user->save()){
$this->_id=$user->user_id;
}
}else{
$this->_id=$u[0]->user_id;
}
$this->setState('user_id', $this->_id);
$this->setState('display_name',$array['display_name']);
$this->setState('name',$array['name']);
$this->setState('email',$array['email']);
$user=User::model()->findByAttributes(array('user_id'=>$this->_id));
if(count($user)>0)
{
if($user->level==1)
{
$this->setState('role', 'user');
}
else if($user->level==0)
{
$this->setState('role','admin');
}
$this->errorCode=self::ERROR_NONE;
}else{
$this->errorCode=self::ERROR_USERNAME_INVALID;
}
return !$this->errorCode;
}
Please help.
Upvotes: 0
Views: 507
Reputation: 56
You should verify that id from authassignment table is the same as the id from the user table. It should be 1 in both cases.
Also verify that once you log in, you are indeed the superuser. You can check that with isSuperuser method. If you are not the super user you can set yourself to superuser via setSuperuser(bool) method.
Upvotes: 1