The assignment revoked, the user 'jam' has no role by name 'marketer'.
All Rbac functions works perfectly except the revoke.
2016-10-18 06:27:43 [error][yii\base\ErrorException:8] exception 'yii\base\ErrorException' with message 'Trying to get property of non-object' in /var/www/mysite/vendor/yiisoft/yii2/rbac/DbManager.php:821
Stack trace:
2016-10-18 06:27:43 [info][application] $_GET = [
'role' => 'marketer'
'userid' => '1'
]
| Q | A |
| --- | --- |
| Yii version | 2.0.6 |
| PHP version | 7.0.11-1+deb.sury.org~xenial+1 |
| Operating system | Ubuntu 16.04 LTS xenial |
AccessController revoke method:
`/**
* Удаление роли пользователя
* @param string $role имя роли
* @param int $userid идентификатор пользователя
* @throws NotFoundHttpException
* @return \yii\web\Response
*/
public function actionRevoke($role, $userid) {
$auth = Yii::$app->authManager;
$model = $auth->getAssignment($role, $userid);
if (empty($model))
throw new NotFoundHttpException("There is no assignment \"$role\" for user \"$userid\".");
$res = $auth->revoke($role, $userid);
if (!$res)
Yii::$app->session->setFlash('danger', Yii::t("yii", "Error"));
return $this->redirect(['assign', "userid"=>$userid]);
}`
revoke is expecting a yii\rbac\Role object not a string.
$role = $auth->getRole($roleName);
$res = $auth->revoke($role, $userid);
Thank you, sorry it's my fault
Most helpful comment
revokeis expecting ayii\rbac\Roleobject not a string.