Check if user has the permission
@param string $permission
@param UserInterface $user
@return boolean
978302
public function grantAccessByPermission($permission, UserInterface $user = null)
    {
        $user = $user ? : $this->currentUser();
        return in_array($permission, $this->gatherPermissions($user));
    }
1175567
public function remove(UserInterface $user): bool
    {
        try {
            $this->storage->delete(User::TABLE, $user->getId()->toString());
        } catch (Exception $e) {
            throw $e;
        }
        return true;
    }
217857
public function findWithoutPermission($permission)
    {
        return array_filter(
            $this->findAll(),
            function ($user) use ($permission) {
                return $user->hasnt($permission);
            }
        );
    }
195123
public function hasPermission($permission)
    {
        return $this->roles->each(function ($role) use ($permission) {
            if (in_array($permission, explode(',', $role->permissions))) {
                return true;
            }
        });

        return false;
    }
1119326
public function hasPermission($permission)
    {
        if ($this->id == self::ADMINISTRATOR_ID) {
            return true;
        }

        return $this->permissions->contains('permission', $permission);
    }
425270
protected function checkAccess($permission): bool
    {
        return $this->app->core->user->permissions[$this->app->getName()]->allowedTo($permission);
    }
640400
public function getPermission($permission)
    {
        if ($permission instanceof PermissionInterface) {
            $permission =   $permission->key;
        }

        return $this->permissions()
            ->key($permission)
            ->first();
    }
688158
function enforce($Permission, $UserID = null)
	{
	if ($UserID === null)
                throw new \RbacUserNotProvidedException ("\$UserID is a required argument.");

		if (! $this->check($Permission, $UserID)) {
            header('HTTP/1.1 403 Forbidden');
            die("<strong>Forbidden</strong>: You do not have permission to access this resource.");
        }

        return true;
	}
1115461
public function hasOnePermission($permission)
    {
        foreach ($this->getArrayFrom($permission) as $permission) {
            if ($this->checkPermission($permission)) {
                return true;
            }
        }

        return false;
    }
938036
public function has($id, $permission, $all = true)
    {
        if (! $user = $this->findUserById($id)) {
            return false;
        }

        return $user->has($permission, $all);
}
24480
public function isEqualTo(UserInterface $user)
    {
        if ($user->getRoles() !== $this->getRoles()) {
            return false;
        }

        if ($this->username !== $user->getUsername()) {
            return false;
        }

        if ($this->id !== $user->getId()) {
            return false;
        }

        return true;
    }
1088008
public function hasPermission($permission) {
		$role = new role($this->user->role->name);

		return $role->hasPermission($permission);
	}
1108313
public function attachPermission($permission)
    {
        if ($this->getPermissions()->contains($permission)) {
            return true;
        }
        $this->permissions = null;

        return $this->userPermissions()->attach($permission);
    }
256461
public function isGranted(UserInterface $user, $attributes, OwnedByUserModelInterface $model = null): bool
    {
        foreach ($this->authorizations as $authorization) {
            if ($authorization->isGranted($user, $attributes, $model)) {
                return true;
            }
        }

        return false;
    }
1102389
public function hasPermission($permission)
    {
        if (!$this->permissions->where('token', $permission)->isEmpty()) {
            return true;
        }

        foreach ($this->groups as $group) {
            foreach ($group->roles as $role) {
                if (!$role->permissions->where('token', $permission)->isEmpty()) {
                    return true;
                }
            }
        }

        foreach ($this->roles as $role) {
            if (!$role->permissions->where('token', $permission)->isEmpty()) {
                return true;
            }
        }

        return false;
    }
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);
    }
102635
public function grantAccess($roleOrPermission, UserInterface $user = null)
    {
        $user = $user ? : $this->currentUser();

        if (is_array($roleOrPermission) && $this->grantAccessByRoles($roleOrPermission, $user)) {
            return true;
        } else if (is_array($roleOrPermission) && $this->grantAccessByPermissions($roleOrPermission, $user)) {
            return true;
        } else if ($this->grantAccessByRole($roleOrPermission, $user)) {
            return true;
        } else if ($this->grantAccessByPermission($roleOrPermission, $user)) {
            return true;
        }

        return false;
    }