public function actionRevoke($roleName, $email)
    {
        $user = UserModel::findByEmail($email);

        if (empty($user)) {
            throw new Exception(Yii::t('yii2mod.user', 'User is not found.'));
        }

        $role = $this->findRole($roleName);

        if (!in_array($roleName, array_keys($this->_authManager->getRolesByUser($user->id)))) {
            $this->stdout(Yii::t('yii2mod.user', 'This role is not assigned to this user.') . "\n", Console::FG_RED);

            return self::EXIT_CODE_NORMAL;
        }

        $this->_authManager->revoke($role, $user->id);

        $this->stdout(Yii::t('yii2mod.user', 'The role has been successfully revoked from the user.') . "\n", Console::FG_GREEN);

        return self::EXIT_CODE_NORMAL;
    }
public function actionRevoke($roleName, $email)
    {
        $user = UserModel::findByEmail($email);

        if (empty($user)) {
            throw new Exception(Yii::t('yii2mod.user', 'User is not found.'));
        }

        $role = $this->findRole($roleName);

        if (!in_array($roleName, array_keys($this->_authManager->getRolesByUser($user->id)))) {
            $this->stdout(Yii::t('yii2mod.user', 'This role is not assigned to this user.') . "\n", Console::FG_RED);

            return self::EXIT_CODE_NORMAL;
        }

        $this->_authManager->revoke($role, $user->id);

        $this->stdout(Yii::t('yii2mod.user', 'The role has been successfully revoked from the user.') . "\n", Console::FG_GREEN);

        return self::EXIT_CODE_NORMAL;
    }
public function actionRevoke ( $ roleName , $ email ) { $ user = UserModel :: findByEmail ( $ email ) ; if ( empty ( $ user ) ) { throw new Exception ( Yii :: t ( 'yii2mod.user' , 'User is not found.' ) ) ; } $ role = $ this -> findRole ( $ roleName ) ; if ( ! in_array ( $ roleName , array_keys ( $ this -> _authManager -> getRolesByUser ( $ user -> id ) ) ) ) { $ this -> stdout ( Yii :: t ( 'yii2mod.user' , 'This role is not assigned to this user.' ) . "\n" , Console :: FG_RED ) ; return self :: EXIT_CODE_NORMAL ; } $ this -> _authManager -> revoke ( $ role , $ user -> id ) ; $ this -> stdout ( Yii :: t ( 'yii2mod.user' , 'The role has been successfully revoked from the user.' ) . "\n" , Console :: FG_GREEN ) ; return self :: EXIT_CODE_NORMAL ; }
Revoke role from the user

@param $roleName
@param $email

@return int

@throws Exception
Revoke role from the user