Skip to content

Commit

Permalink
Use User::can()' in hasPermission()' of the authentication manager
Browse files Browse the repository at this point in the history
  • Loading branch information
lippserd committed Sep 18, 2014
1 parent af58732 commit 7949102
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions library/Icinga/Authentication/Manager.php
Expand Up @@ -145,25 +145,16 @@ public function isAuthenticated($ignoreSession = false)
/**
* Whether an authenticated user has a given permission
*
* This is true if the user owns this permission, false if not.
* Also false if there is no authenticated user
*
* TODO: I'd like to see wildcard support, e.g. module/*
*
* @param string $permission Permission name
* @return bool
*
* @return bool True if the user owns the given permission, false if not or if not authenticated
*/
public function hasPermission($permission)
{
if (! $this->isAuthenticated()) {
return false;
}
foreach ($this->user->getPermissions() as $p) {
if ($p === $permission) {
return true;
}
}
return false;
return $this->user->can($permission);
}

/**
Expand Down

0 comments on commit 7949102

Please sign in to comment.