Remove a permission from a user
@param  Reflex\Lockdown\Users\UserInterface|string             $user
@param  Reflex\Lockdown\Permissions\PermissionInterface|string $permission
@return boolean
350168
public function removeUserPermission($user, $permission)
    {
        $permissions=   $this->findPermissionByKey($permission);
        $user       =   $this->findUserById($user);

        return $user->remove($permission);
    }
980252
def remove_user_permission(rid, uid, action='full'):
    
    rid = rid.replace('/', '%252F')

    try:
        acl_url = urljoin(_acl_url(), 'acls/{}/users/{}/{}'.format(rid, uid, action))
        r = http.delete(acl_url)
        assert r.status_code == 204
    except DCOSHTTPException as e:
        if e.response.status_code != 400:
            raise
636432
protected function attachPermissionToUser($permission, $userId)
    {
        // Check if user exists
        if ($user = $this->userRepository->findById($userId)) {
            $user->attachPermission($permission);
            $this->info('Permission attached successfully to user');
        } else {
            $this->error('Not possible to attach permission. User not found');
        }
    }
20436
public function disallowUser($permissions, $object, $user = null)
	{
		// if no user is specified, default to the Auth one
		if(is_null($user))
		{
			$user = app('auth')->user();
		}
		
		if(!is_array($permissions))
		{
			$permissions = array($permissions);
		}
		
		foreach($permissions as $permission)
		{
			$this->disallowSinglePermission($permission, $object, $user);
		}
	}
366622
public function removePermission(AbstractCompanyUserPermission $permission): bool
    {
        if (empty($this->permissions)) {
            return true;
        }
        $permissions = $this->permissions;
        $key = array_search($permission->id, array_column($permissions, 'id'), true);
        unset($permissions[$key]); // удаление элемента
        $permissions = array_values($permissions);
        $this->permissions = $permissions;
        return $this->updateModel();
    }
626157
public function detachPermission($permission)
    {
        $permission = Helper::getIdFor($permission, 'permission');

        $this->permissions()->detach($permission);
        $this->flushCache();
        $this->fireLaratrustEvent("permission.detached", [$this, $permission]);

        return $this;
    }
1222577
public function detachPermission(&$permission, $reload = true)
    {
        if ( ! $this->hasPermission($permission))
            return;

        /** @var  \Arcanesoft\Contracts\Auth\Models\Permission  $permission */
        $permission = $this->getPermissionFromGroup($permission);

        event(new DetachingPermissionFromGroup($this, $permission));
        $permission->update(['group_id' => 0]);
        event(new DetachedPermissionFromGroup($this, $permission));

        $this->loadPermissions($reload);
    }
740089
private function checkPermission($permission)
    {
        if (!$permission)
        {
            return;
        }

        $user = $this->securityApi->getUser(true);
        if ($user instanceof Permissible && $user->hasAccess($permission))
        {
            return;
        }

        throw Unauthorized::permissionDenied($permission, $this->securityApi);
    }
633975
public function actionPermission($user, $operation, $permission)
    {
        $user = $this->getUser($user);
        $permission = Yii::$app->authManager->getPermission($permission);
        if ($operation == 'assign') {
            try {
                $assignment = Yii::$app->authManager->assign($permission, $user);
            } catch (\yii\db\IntegrityException $ex) {
                echo "Failed to assign `" . $permission->name . "`.\n";
                echo "Maybe the permission has been assigned.\n";
                return static::EXIT_CODE_ERROR;
            }
            if ($assignment) {
                echo "`$permission->name`" . " assigned to User (" . $user->getID() . ") successfully.\n";
            } else {
                echo "Failed to assign `" . $permission->name . "`.\n";
            }
            return static::EXIT_CODE_NORMAL;
        }
        if ($operation == 'revoke') {
            $assignment = Yii::$app->authManager->revoke($permission, $user);
            if ($assignment) {
                echo "`$permission->name`" . " revoked from User (" . $user->getID() . ").\n";
            } else {
                echo "Failed to revoke `" . $permission->name . "`.\n";
                echo "Maybe the permission has not been assigned yet.\n";
            }
            return static::EXIT_CODE_NORMAL;
        }
        echo "Unrecognized operation: $operation.\n";
        echo "The accepted operations are `assign` and `revoke`.\n";
        return static::EXIT_CODE_ERROR;
    }
1204017
public function detachPermission($permission)
    {
        if (is_object($permission)) {
            $permission = $permission->getKey();
        }

        if (is_array($permission)) {
            return $this->detachPermissions($permission);
        }

        $this->perms()->detach($permission);
    }
165593
public function delete(User $user)
    {
        $this->authorize(UsersPolicy::PERMISSION_DELETE);

        try {
            ($trashed = $user->trashed()) ? $user->forceDelete() : $user->delete();

            $message = $this->transNotification(
                $trashed ? 'deleted' : 'trashed',
                ['name' => $user->full_name],
                $user->toArray()
            );

            return $this->jsonResponseSuccess(compact('message'));
        }
        catch(\Exception $e) {
            return $this->jsonResponseError(['message' => $e->getMessage()], 500);
        }
    }
1022661
public function delete_acl($folder, $user)
    {
        if (!$this->get_capability('ACL')) {
            return false;
        }

        if (!$this->check_connection()) {
            return false;
        }

        return $this->conn->deleteACL($folder, $user);
    }
478468
public function giveUserPermission($user, $permission, $level = 'allow')
    {
        $this->checkPermissionLevel($level);

        $user           =   $this->findUserById($user);
        $permission     =   $this->findPermissionByKey($permission);

        return $user->give($permission, $level);
    }
33352
public function delete(User $user, User $entity)
    {
        if ($entity->id === $user->id) {
            return true;
        }
        return $user->hasPermission('user-delete');
    }
846644
protected function checkPermission($permission = 'manage', $role = 'admin')
    {
        if ($this->auth->guest()) {
            return 401;
        }

        if ($this->auth->user()->can($permission) || $this->auth->user()->hasRole($role)) {
            return true;
        }

        return 403;
    }
1121480
public function removePermission(ChildPermission $permission)
    {
        if ($this->getPermissions()->contains($permission)) { $rolePermission = new ChildRolePermission();

            $rolePermission->setPermission($permission);
            if ($permission->isRolesLoaded()) {
                //remove the back reference if available
                $permission->getRoles()->removeObject($this);
            }

            $rolePermission->setRole($this);
            $this->removeRolePermission(clone $rolePermission);
            $rolePermission->clear();

            $this->collPermissions->remove($this->collPermissions->search($permission));

            if (null === $this->permissionsScheduledForDeletion) {
                $this->permissionsScheduledForDeletion = clone $this->collPermissions;
                $this->permissionsScheduledForDeletion->clear();
            }

            $this->permissionsScheduledForDeletion->push($permission);
        }


        return $this;
    }
1080245
private function restrictPermissions(array $userPermission, array $permissions)
    {
        return $this->mapPermissions($userPermission, $permissions, function($permission1, $permission2) {
            return $permission1 && $permission2;
        });
    }