Skip to content

Commit

Permalink
Merge pull request #174 from silverstripeltd/pulls/update-grant-metho…
Browse files Browse the repository at this point in the history
…d-fix

Bugfix: Check for active controller before access getRequest()
  • Loading branch information
GuySartorelli authored Aug 7, 2022
2 parents ce0b934 + 07487f8 commit 4810235
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,24 @@ public function updateGrant(bool &$grant, ?File $record = null, ?array $args = n
if ($grant) {
return;
}
$session = $session = Controller::curr()->getRequest()->getSession();
if (!Controller::has_curr()) {
return;
}

$session = Controller::curr()->getRequest()->getSession();

if (!$session) {
return;
}

if (!ShareDraftController::getIsViewingPreview()) {
return;
}

if (!$record && $args) {
$record = FileShortcodeProvider::find_shortcode_record($args);
}

if ($record) {
$grant = !$record->hasRestrictedAccess();
}
Expand Down

0 comments on commit 4810235

Please sign in to comment.