Note that there are some explanatory texts on larger screens.

plurals
  1. POYii adding an Admin
    text
    copied!<p>I've been following the instructions here (<a href="http://www.yiiframework.com/doc/guide/1.1/en/topics.auth" rel="nofollow">http://www.yiiframework.com/doc/guide/1.1/en/topics.auth</a>) to add DB based authorization and users with Yii. I can log in with a user defined in the user table, but i cannot log in as an admin. I can see 1 row in my authassignment table with itemname 'admin' with a key to user id 1 - which is the user im using to log in. </p> <p>My authManager looks like this:</p> <pre><code>'authManager'=&gt;array( 'class'=&gt;'CDbAuthManager', 'connectionID'=&gt;'db', 'defaultRoles'=&gt;array('authenticated', 'admin'), ), </code></pre> <p>And the access rules for the particular controller im using are:</p> <pre><code> public function accessRules() { return array( array('allow', // allow all users to perform 'index' and 'view' actions 'actions' =&gt; array('index', 'view'), 'users' =&gt; array('*'), ), array('allow', // allow admin user to perform 'admin' and 'delete' actions 'actions' =&gt; array('admin', 'delete','create', 'update'), 'users' =&gt; array('admin'), ), array('deny', // deny all users 'users' =&gt; array('*'), ), ); } </code></pre> <p>Attempting to use the 'admin' action results in a 403 error. I can't seem to get around this. Any suggestions?</p> <p><strong>EDIT:</strong> So knowing that the bizrule for the admin authitem is <code>return Yii::app()-&gt;user-&gt;name === "admin";</code>, I changed the username of the user to 'admin' and it of course worked. What do I need to change the bizrule to to let anyway who is an admin in the authassignment table log in as a admin?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload