mint 0 Posted June 26, 2012 Report Share Posted June 26, 2012 I have created Rbac with superadmin,admin1,normaluser. I want to check weather the user is logged in as superadmin, admin1,normaluser depending on the database column "access" value in tbl_user table, if "access"=0 then user should be superadmin, if "access"=1 then user should be admin1 and if "access"=2 then user should be normaluser. RBAC authorization hierarchy was created by yiic shell, all the database schema has been defined. I cannot figure out how to proceed further than creating authorization hierarchy and how to write code to check a user according to roles. Here is RbacCommand.php http://pastebin.com/BKdYM4eg Quote Link to post Share on other sites
Larry 433 Posted July 4, 2012 Report Share Posted July 4, 2012 Sorry for the delay; I was out of town. Are you still having problems with this? Quote Link to post Share on other sites
mint 0 Posted July 12, 2012 Author Report Share Posted July 12, 2012 Thanks, the problem is solved. I did this in the UserIdentity if($user->access==='0') { if(!Yii::app()->authManager->isAssigned('superadmin',$this->_id)) { Yii::app()->authManager->assign('superadmin', $this->_id); } } else if($user->access==='1') { if(!Yii::app()->authManager->isAssigned('admin1',$this->_id)) { Yii::app()->authManager->assign('admin1', $this->_id); } } else if($user->access==='2') { if(!Yii::app()->authManager->isAssigned('normaluser',$this->_id)) { Yii::app()->authManager->assign('normaluser', $this->_id); } } And Checked if the user has the permission in the respective action Quote Link to post Share on other sites
Larry 433 Posted July 13, 2012 Report Share Posted July 13, 2012 Excellent. Kudos for figuring that out and thanks for sharing. Sorry I couldn't have helped. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.