Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Authorization Hierarchy Code

$
0
0
Hi All,

Every Forum topic and/or doc or blog on authorization heirarchy say:
Run following code once in by placing it an any executabel file of your yii web app:

$auth=Yii::app()->authManager;

$bizRule='return !Yii::app()->user->isGuest;';
$auth->createRole('authenticated', 'authenticated user', $bizRule);

$bizRule='return Yii::app()->user->isGuest;';
$auth->createRole('guest', 'guest user', $bizRule);

$role = $auth->createRole('admin', 'administrator');
$auth->assign('admin',1); // adding admin to first user created

$auth->save();

I actually dont get where to put this code and execute. Do i need to execute this from shell. Is there a way i can run this from browser coz i dont have shell access on server.

I tried by putting the above code in protected/view/user/auth.php and tried to run it as http://localhost/yii/test/index.php?r=user/auth. It returns me with Error 404.

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>