Make all front-end routes require authentication

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Make all front-end routes require authentication

Post by MikaelNazarenko » 29 Jul 2019, 20:06

Can anybody, please, give me good way how to do it ?

I edited this file /var/www/schmuck/config/shop.php

Code: Select all

 'default' => ['prefix' => 'shop', 'middleware' => ['web', 'auth']],
But I also need to remove /shop from url, so it must work with /. I couldn't combine it(

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Make all front-end routes require authentication

Post by aimeos » 29 Jul 2019, 21:21

Remove the "prefix" or set it to "/"
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: Make all front-end routes require authentication

Post by MikaelNazarenko » 30 Jul 2019, 06:29

Great thank you, but in the file /var/www/schmuck/config/shop.php I have the following content:

Code: Select all

'default' => ['prefix' => '/', 'middleware' => ['web', 'auth']],
When I go to / it redirects me to /login and the I have error:

ERR_TOO_MANY_REDIRECTS

if I comment this code

Code: Select all

'default' => ['prefix' => '/', 'middleware' => ['web', 'auth']],
then login page works

The routes/web.php file consists only

Code: Select all

Auth::routes();
Please, help me to solve it

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Make all front-end routes require authentication

Post by aimeos » 30 Jul 2019, 07:34

The order of the routes is wrong because the Auth routes are after the Aimeos routes if you execute

Code: Select all

./artisan route:list
We haven't found a way yet to move the Auth routes up to the front ...
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Make all front-end routes require authentication

Post by aimeos » 30 Jul 2019, 17:25

You can try to add "Auth::routes();" routes in ./routes/web.php first and overwrite the Aimeos tree and detail routes afterwards:

Code: Select all

|        | GET|POST|HEAD | shop/{d_name}/{d_pos?}/{d_prodid?}                            | aimeos_shop_detail           | Aimeos\Shop\Controller\CatalogController@detailAction                  | web          |
|        | GET|POST|HEAD | shop/{f_name}~{f_catid}                                       | aimeos_shop_tree             | Aimeos\Shop\Controller\CatalogController@treeAction                    | web          |
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply