dimanche 1 septembre 2019

Laravel 5.8: How to exclude a page from default redirection when user is not authorized

In Laravel all pages are redirected to login page for unauthorized users (Guest). How to exclude a page (e.q. Index) from this redirection? I tried changing file below and set return route('login') to return route('index') but it makes infinite index call and Firefox says:

The page isn't redirecting properly. Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

File:

Middleware/Authenticate.php

     //Get the path the user should be redirected to when they are not authenticated.

protected function redirectTo($request)
    {
        if (! $request->expectsJson()) {
            return route('login');
        }
    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire