Note that there are some explanatory texts on larger screens.

plurals
  1. POCException error with RBAC ACL using authManager in yiic shell tool
    text
    copied!<p>I get the below error when running a custom command from the <code>yiic</code> shell. I am using the latest <code>MAMP 2.0.2</code> on <code>OS X 10.7.2</code></p> <p>I am not sure what the error means by <code>reader</code> or <code>member</code> does not exist?</p> <p>Line 56 is: <code>$role-&gt;addChild("reader");</code> and the full code of the custom command and and terminal output is below:</p> <pre><code>users-MacBook-Air:protected user$ ./yiic shell ../index.php Yii Interactive Tool v1.1 (based on Yii v1.1.2) Please type 'help' for help. Type 'exit' to quit. &gt;&gt; rbac This command will create three roles: Owner, Member, and Reader and the following permissions: create, read, update and delete user create, read, update and delete project create, read, update and delete issue Would you like to continue? [Yes|No]y exception 'CException' with message 'Either "member" or "reader" does not exist.' in /Users/user/Dropbox/localhost/yii/framework/web/auth/CDbAuthManager.php:203 Stack trace: #0 /Users/user/Dropbox/localhost/yii/framework/web/auth/CAuthItem.php(185): CDbAuthManager-&gt;addItemChild('member', 'reader') #1 /Users/user/Dropbox/localhost/trackstar/protected/commands/shell/RbacCommand.php(56): CAuthItem-&gt;addChild('reader') #2 /Users/user/Dropbox/localhost/yii/framework/cli/commands/ShellCommand.php(144): RbacCommand-&gt;run(Array) #3 /Users/user/Dropbox/localhost/yii/framework/cli/commands/ShellCommand.php(99): ShellCommand-&gt;runShell() #4 /Users/user/Dropbox/localhost/yii/framework/console/CConsoleCommandRunner.php(62): ShellCommand-&gt;run(Array) #5 /Users/user/Dropbox/localhost/yii/framework/console/CConsoleApplication.php(88): CConsoleCommandRunner-&gt;run(Array) #6 /Users/user/Dropbox/localhost/yii/framework/base/CApplication.php(135): CConsoleApplication-&gt;processRequest() #7 /Users/user/Dropbox/localhost/yii/framework/yiic.php(33): CApplication-&gt;run() #8 /Users/user/Dropbox/localhost/trackstar/protected/yiic.php(7): require_once('/Users/user/Dro...') #9 /Users/user/Dropbox/localhost/trackstar/protected/yiic(4): require_once('/Users/user/Dro...') #10 {main} &gt;&gt; </code></pre> <p>RBAC Command:</p> <pre><code>&lt;?php class RbacCommand extends CConsoleCommand { private $_authManager; public function getHelp() { return "&lt;&lt;&lt;EOD USAGE rbac DESCRIPTION This command generates an initial RBAC authorization hierarchy. EOD"; } public function run($args) { if(($this-&gt;_authManager=Yii::app()-&gt;authManager)===null) { echo "Error: an authorization manager, named 'authManager' must be configured to use this command.\n"; echo "If you already added 'authManager' component in applicaton configuration,\n"; echo "please quit and re-enter the yiic shell.\n"; return; } echo "This command will create three roles: Owner, Member, and Reader and the following permissions:\n"; echo "create, read, update and delete user\n"; echo "create, read, update and delete project\n"; echo "create, read, update and delete issue\n"; echo "Would you like to continue? [Yes|No]"; if(!strncasecmp(trim(fgets(STDIN)),'y',1)) { $this-&gt;_authManager-&gt;clearAll(); $this-&gt;_authManager-&gt;createOperation("createUser","create a new user"); $this-&gt;_authManager-&gt;createOperation("readUser","read user profile information"); $this-&gt;_authManager-&gt;createOperation("updateUser","update a users information"); $this-&gt;_authManager-&gt;createOperation("deleteUser","remove a user from a project"); $this-&gt;_authManager-&gt;createOperation("createProject","create a new project"); $this-&gt;_authManager-&gt;createOperation("readProject","read project information"); $this-&gt;_authManager-&gt;createOperation("updateProject","update project information"); $this-&gt;_authManager-&gt;createOperation("deleteProject","delete a project"); $this-&gt;_authManager-&gt;createOperation("createIssue","create a new issue"); $this-&gt;_authManager-&gt;createOperation("readIssue","read issue information"); $this-&gt;_authManager-&gt;createOperation("updateIssue","update issue information"); $this-&gt;_authManager-&gt;createOperation("deleteIssue","delete a issue"); $role=$this-&gt;_authManager-&gt;createRole("member"); $role-&gt;addChild("reader"); $role-&gt;addChild("createIssue"); $role-&gt;addChild("updateIssue"); $role-&gt;addChild("deleteIssue"); $role=$this-&gt;_authManager-&gt;createRole("owner"); $role-&gt;addChild("reader"); $role-&gt;addChild("member"); $role-&gt;addChild("createUser"); $role-&gt;addChild("updateUser"); $role-&gt;addChild("deleteUser"); $role-&gt;addChild("createProject"); $role-&gt;addChild("updateProject"); $role-&gt;addChild("deleteProject"); } } } ?&gt; </code></pre>
 

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