Yii framework : role based access control

和自甴很熟 提交于 2019-12-23 10:26:56

问题


I am implementing role based access control using yii framework for the application mentioned in the Agile web application development using yii framework book.I have implemented every thing up to page number 189.

page number 189 says that following method can be used to check whether user is allowed to perform some action or not.

If( Yii::app()->user->checkAccess('createIssue')) { //perform needed logic }

but this method always return false for users who have been assigned to createIssue operation

following is the database diagram for RBAC

i am linking UserID and role for authassignment table using following command.

$auth=Yii::app()->authManager; $auth->assign('member',1);

As you can see my user table and authassignment table does not have direct relationship.

And i have configured main.php file in configuration folder

These are the all we have done so far and could any body share your knowledge with me if any thing is missing here. Thanks in advance for any help.


回答1:


Come on, man! Of course there must be a direct relationship between users and assigments. In the following piece of code:

$auth=Yii::app()->authManager; $auth->assign('member',1)

'member' belongs to authiments, and '1' is the id of the user being assigned with that role. "userid", in the "authassigment" table, must point to users table.



来源:https://stackoverflow.com/questions/8847914/yii-framework-role-based-access-control

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!