Yii Framework Forum: Yii2-admin role-based aceess control(RBAC) - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii2-admin role-based aceess control(RBAC) Rate Topic: -----

#1 User is offline   Sherin Jose 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 03-January 13
  • Location:Kochi, India

Posted 04 August 2016 - 12:39 AM

I am using yii2-admin for role-based access control. In this module, we need to check the access in each action like

if (\Yii::$app->user->can('createPost')) {
   // create post
}

or like

public function behaviors()
{
    return [
        'access' => [
            'class' => AccessControl::className(),
            'rules' => [
                [
                    'allow' => true,
                    'actions' => ['create'],
                    'roles' => ['createPost'],
                ],
            ]
        ]
    ];
}

But in yii-1 the rights module provides an option to check the access control by extending a controller (RController). Do we have such an option in yii2-admin ?
0

#2 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 3,411
  • Joined: 16-February 11
  • Location:Japan

Posted 04 August 2016 - 06:39 AM

/* Moved from "General Discussions" to "Extensions" */

The extension doesn't provide an extended Controller like "RController".
But it does provide an extended AccessControl filter, which is a very convenient component. It uses "route" permissions in the RBAC hierarchy to check access to controllers/actions, which works almost the same as yii-rights does for Yii 1.x.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users