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

How To Use Yii Cauthmanager ,cphpauthmanager

$
0
0
Hi,

I have waste my lots of time to clearing , how to use Yii CAuthManager ,CPhpAuthManager but not get any idea,
How can i start this,where I can put this code:
 $ Auth = Yii :: app () -> authManager; 

  $ Auth-> createOperation ('createPost', 'create a post'); 
  $ Auth-> createOperation ('readPost', 'read a post'); 
  $ Auth-> createOperation ('updatePost', 'update a post'); 
  $ Auth-> createOperation ('deletePost', 'delete a post'); 

  $ BizRule = 'return Yii :: app () -> user-> id == $ params ["post"] -> authID;'; 
  $ Task = $ auth-> createTask ('updateOwnPost', 'update a post by author himself', $ bizRule); 
  $ Task-> addChild ('updatePost'); 

  $ Role = $ auth-> createRole ('reader'); 
  $ Role-> addChild ('readPost'); 

  $ Role = $ auth-> createRole ('author'); 
  $ Role-> addChild ('reader'); 
  $ Role-> addChild ('createPost'); 
  $ Role-> addChild ('updateOwnPost'); 

  $ Role = $ auth-> createRole ('editor'); 
  $ Role-> addChild ('reader'); 
  $ Role-> addChild ('updatePost'); 

  $ Role = $ auth-> createRole ('admin'); 
  $ Role-> addChild ('editor'); 
  $ Role-> addChild ('author'); 
  $ Role-> addChild ('deletePost'); 

  $ Auth-> assign ('reader', 'readerA'); 
  $ Auth-> assign ('author', 'authorB'); 
  $ Auth-> assign ('editor', 'editorC'); 
  $ Auth-> assign ('admin', 'adminD'); 


no idea where I put above code in my controller or any othere file?

Viewing all articles
Browse latest Browse all 18717

Trending Articles



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