mint Posted June 26, 2012 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 Link to comment Share on other sites More sharing options...
Larry Posted July 4, 2012 Share Posted July 4, 2012 Sorry for the delay; I was out of town. Are you still having problems with this? Link to comment Share on other sites More sharing options...
mint Posted July 12, 2012 Author 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 Link to comment Share on other sites More sharing options...
Larry Posted July 13, 2012 Share Posted July 13, 2012 Excellent. Kudos for figuring that out and thanks for sharing. Sorry I couldn't have helped. Link to comment Share on other sites More sharing options...
Recommended Posts