diff --git a/src/Extensions/ShareDraftContentFileShortcodeProviderExtension.php b/src/Extensions/ShareDraftContentFileShortcodeProviderExtension.php index aef709c..3651302 100644 --- a/src/Extensions/ShareDraftContentFileShortcodeProviderExtension.php +++ b/src/Extensions/ShareDraftContentFileShortcodeProviderExtension.php @@ -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(); }