mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
FIX Members with no ID inherit logged in user permission
This commit is contained in:
parent
d63441623a
commit
4335d8ed22
@ -160,7 +160,11 @@ class Permission extends DataObject implements TemplateGlobalProvider {
|
|||||||
if(!$member) {
|
if(!$member) {
|
||||||
$memberID = $member = Member::currentUserID();
|
$memberID = $member = Member::currentUserID();
|
||||||
} else {
|
} else {
|
||||||
$memberID = (is_object($member)) ? $member->ID : $member;
|
$memberID = (is_object($member)) ? $member->ID : $member;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$memberID) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn the code into an array as we may need to add other permsissions to the set we check
|
// Turn the code into an array as we may need to add other permsissions to the set we check
|
||||||
|
@ -124,4 +124,14 @@ class PermissionTest extends SapphireTest {
|
|||||||
Config::inst()->remove('Permission', 'hidden_permissions');
|
Config::inst()->remove('Permission', 'hidden_permissions');
|
||||||
$this->assertContains('CMS_ACCESS_LeftAndMain', $permissionCheckboxSet->Field());
|
$this->assertContains('CMS_ACCESS_LeftAndMain', $permissionCheckboxSet->Field());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testEmptyMemberFails() {
|
||||||
|
$member = new Member();
|
||||||
|
$this->assertFalse($member->exists());
|
||||||
|
|
||||||
|
$this->logInWithPermission('ADMIN');
|
||||||
|
|
||||||
|
$this->assertFalse(Permission::checkMember($member, 'ADMIN'));
|
||||||
|
$this->assertFalse(Permission::checkMember($member, 'CMS_ACCESS_LeftAndMain'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user