Skip to content

unexpected result from auth()->user()->can('[permission-name]') #2473

Answered by drbyte
mahmoudsabryksi asked this question in Q&A
Discussion options

You must be logged in to vote

I think there is no check for all permissions given to users through role or direct permissions,

You can see here that the hasPermissionTo() function checks both direct permissions and permissions via roles:

public function hasPermissionTo($permission, $guardName = null): bool
{
if ($this->getWildcardClass()) {
return $this->hasWildcardPermission($permission, $guardName);
}
$permission = $this->filterPermission($permission, $guardName);
return $this->hasDirectPermission($permission) || $this->hasPermissionViaRole($permission);
}

And calling can call…

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
3 replies
@parallels999
Comment options

@mahmoudsabryksi
Comment options

@parallels999
Comment options

Comment options

You must be logged in to vote
1 reply
@mahmoudsabryksi
Comment options

Comment options

You must be logged in to vote
2 replies
@drbyte
Comment options

Answer selected by mahmoudsabryksi
@mahmoudsabryksi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants