User: Consider the required permission more important if it has a wildcard

refs #9202
This commit is contained in:
Johannes Meyer 2015-06-02 12:01:02 +02:00
parent 7213379cac
commit 267e71f38b
2 changed files with 4 additions and 2 deletions

View File

@ -426,7 +426,7 @@ class User
// matches
$any = strpos($requiredPermission, '*');
foreach ($this->permissions as $grantedPermission) {
if ($any !== false && strpos($grantedPermission, '*') === false) {
if ($any !== false) {
$wildcard = $any;
} else {
// If the permit contains a wildcard, grant the permission if it's related to the permit

View File

@ -67,13 +67,15 @@ class UserTest extends BaseTestCase
'test',
'test/some/specific',
'test/more/*',
'test/wildcard-with-wildcard/*'
'test/wildcard-with-wildcard/*',
'test/even-more/specific-with-wildcard/*'
));
$this->assertTrue($user->can('test'));
$this->assertTrue($user->can('test/some/specific'));
$this->assertTrue($user->can('test/more/everything'));
$this->assertTrue($user->can('test/wildcard-with-wildcard/*'));
$this->assertTrue($user->can('test/wildcard-with-wildcard/sub/sub'));
$this->assertTrue($user->can('test/even-more/*'));
$this->assertFalse($user->can('not/test'));
$this->assertFalse($user->can('test/some/not/so/specific'));
$this->assertFalse($user->can('test/wildcard2/*'));