Page restriction
Created 5 years ago by cyno

Hi, 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',
        ],

ryanthompson  —  5 years ago

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.

cyno  —  5 years ago

Problem is if I set allowed roles if im loggod out its not visible in the menu. Also even if set it, for some reason if i access the url i can still see the page.

ryanthompson  —  5 years ago

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.

cyno  —  5 years ago

Also om monday im gonna send u every info regarding this.

cyno  —  5 years ago

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.

cyno  —  5 years ago

@ryanthompson any updates on this by chance?

ryanthompson  —  5 years ago

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?