Option for page visibility with frontend authentication. #152
Replies: 2 comments 2 replies
-
You can use any of Boxes' (or October's) events to run your check, then return an Exception or redirect if the user has no access: Event::listen('cms.page.display', function (\Cms\Classes\Controller $controller, string $url, \Cms\Classes\Page $page, $result) {
if ($url === '/no-access' && ! $userHasSession) {
return Response::make('Access denied', 401);
}
}); You can combine it with page specific data to manage the access control directly in the Boxes editor: https://docs.boxes.offline.ch/use-cases/page-specific-data.html |
Beta Was this translation helpful? Give feedback.
-
Hi Tobias, I've added 2 custom config fields to the boxes page, "restricted_page" (checkbox) and "restricted_page_redirect" (pagefinder) to manage the access control per page and added the following code to check if the visitor is logged-in and not in the boxes editor. If they aren't logged-in, they should be redirected to the set redirect page, but the redirect isn't happening. The if statements are all correct and working properly, but nothing happens. Do you have any idea how to fix this? Code:
Thanks in advance! |
Beta Was this translation helpful? Give feedback.
-
For a project we are working on, we need an option to block access to a page unless you are logged in on the frontend via de Rainlab user plugin.
Could a function like this be created?
Beta Was this translation helpful? Give feedback.
All reactions