-
-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don’t keep user object in memory cache
Made the permission checks return stale results if the user changed during the request
- Loading branch information
1 parent
b6e81f9
commit 13ea6fc
Showing
3 changed files
with
53 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,7 +74,6 @@ public function testWithNoAdmin($action) | |
'index' => '/dev/null' | ||
], | ||
'roles' => [ | ||
['name' => 'admin'], | ||
[ | ||
'name' => 'editor', | ||
'permissions' => [ | ||
|
@@ -88,36 +87,41 @@ public function testWithNoAdmin($action) | |
'update' => false | ||
], | ||
'users' => [ | ||
'changeEmail' => false, | ||
'changeLanguage' => false, | ||
'changeName' => false, | ||
'changePassword' => false, | ||
'changeRole' => false, | ||
'create' => false, | ||
'delete' => false, | ||
'update' => false | ||
'changeEmail' => true, | ||
'changeLanguage' => true, | ||
'changeName' => true, | ||
'changePassword' => true, | ||
'changeRole' => true, | ||
'create' => true, | ||
'delete' => true, | ||
'update' => true | ||
] | ||
] | ||
] | ||
], | ||
'user' => 'editor@getkirby.com', | ||
'user' => 'editor1@getkirby.com', | ||
'users' => [ | ||
[ | ||
'email' => 'admin@getkirby.com', | ||
'role' => 'admin' | ||
'email' => 'editor1@getkirby.com', | ||
'role' => 'editor' | ||
], | ||
[ | ||
'email' => 'editor@getkirby.com', | ||
'email' => 'editor2@getkirby.com', | ||
'role' => 'editor' | ||
] | ||
], | ||
]); | ||
|
||
$user = $app->user(); | ||
$perms = $user->permissions(); | ||
// `user` permissions are disabled | ||
$user1 = $app->user(); | ||
$perms1 = $user1->permissions(); | ||
$this->assertSame('editor', $user1->role()->name()); | ||
$this->assertFalse($perms1->can($action)); | ||
|
||
$this->assertSame('editor', $user->role()->name()); | ||
$this->assertFalse($perms->can($action)); | ||
// `users` permissions are enabled | ||
$user2 = $app->user('[email protected]'); | ||
$perms2 = $user2->permissions(); | ||
$this->assertTrue($perms2->can($action)); | ||
} | ||
|
||
public function testChangeSingleRole() | ||
|