Page restriction
Created 5 years ago by cynoHi, So I'm trying to make a page only accessable when user is logged in. It's working on views/pages I created in a module, but not working for pages I created on the admin dashboard. I've tried restricting it in page options, which makes it disappear from the menu (I don't want that), also tried overriding the route in the theme service provider (not working either). Any ideas?
'profile' => [
'anomaly.module.users::role' => [
'user',
'admin',
],
'anomaly.module.users::redirect' => '/login',
'anomaly.module.users::message' => 'Please log in to continue.',
'uses' => 'Anomaly\PagesModule\Http\Controller\PagesController@view',
],
Ah you're using structure for your menus. One way to solve this would be to use Navigation for your menu so it's independent.
Double check on that allowed roles cause if you are indeed logged out you won't see a protected page unless the guest role is allowed.
So I've double checked it, and indeed if its set to Admin, User as allower roles, it dissapears from the structure. But if I access the url directly, the page still loads (you can check at dev.hustle-app.com/profile). Seems like a wierd bug to me.
@ryanthompson any updates on this by chance?
This is what is protecting pages: https://github.com/anomalylabs/pages-module/blob/2.6/src/Page/PageAuthorizer.php
Can you find anything strange about your issue here?
The pages module has it's own "allowed roles" in options that you can do this with. Keep in mind admin's have access to everything so it won't apply to you while logged in.