Skip to content

Commit

Permalink
FIX LeftAndMainSubsites::canAccess() now accepts a Member argument an…
Browse files Browse the repository at this point in the history
…d falls back to the session member
  • Loading branch information
robbieaverill committed Jun 25, 2019
1 parent 6a8da1c commit 800f09d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions code/extensions/LeftAndMainSubsites.php
Expand Up @@ -183,11 +183,16 @@ public function shouldChangeSubsite($adminClass, $recordSubsiteID, $currentSubsi

/**
* Check if the current controller is accessible for this user on this subsite.
*
* @param Member $member
*/
public function canAccess()
public function canAccess(Member $member = null)
{
if (!$member) {
$member = Member::currentUser();
}

// Admin can access everything, no point in checking.
$member = Member::currentUser();
if ($member &&
(
Permission::checkMember($member, 'ADMIN') || // 'Full administrative rights' in SecurityAdmin
Expand All @@ -209,10 +214,12 @@ public function canAccess()
/**
* Prevent accessing disallowed resources. This happens after onBeforeInit has executed,
* so all redirections should've already taken place.
*
* @param Member $member
*/
public function alternateAccessCheck()
public function alternateAccessCheck(Member $member = null)
{
return $this->owner->canAccess();
return $this->owner->canAccess($member);
}

/**
Expand Down

0 comments on commit 800f09d

Please sign in to comment.