How to make entire site only accessible by users?

nemesis - 2 months ago

Hi, I am trying to make my whole site only accessible by users and admins. Guests should be redirected to the login page.

I did find the 'Allowed Roles' option at the Pages Module -> Pages where you can set a page to User only, but basically I want to turn that around. Default acces by User only, unless explicitly allowed for Guest in the Page Module.

Am I overlooking an option that you can set a site to that behaviour? Or is there an easy way to program that in?

Thanks for your help!

ryanthompson - 2 months ago

I would use your theme or some addon to register a middleware and check there. Something kinda like this: https://github.com/anomalylabs/users-module/blob/2.2/src/Http/Middleware/AuthorizeControlPanel.php