Can i change the user role? RBAC

I’m using yii2 role based access control (RBAC) system. I defined roles and permissions, defined rules, assigned roles to users.

Everything works fine. But i want to update assigned roles to users.

For Example:


Yii::$app->authManager->assign('admin', '11');

Here i did user id 11 admin. Now i want to update and change. I want to make this user manager.

When i try:


Yii::$app->authManager->assign('manager', '11');

This user have admin + manager roles. I just want to update this user role admin to manager.

How can i do this?

You can revoke an assigned role from a user.

http://www.yiiframework.com/doc-2.0/yii-rbac-managerinterface.html#revoke()-detail

I’m using revoke like this:


 Yii::$app->authManager->revoke( $first_user_role, $this->id );

Then i will asign again.

Thanks!