samedi 6 mai 2017

Laravel 5.4 redirect to login if unauthenticated

I have a custom login page for my laravel app. However, i have modified my Handler.php to first look like this

protected function unauthenticated($request, AuthenticationException $exception)
    {
        if ($request->expectsJson()) {
            return response()->json(['error' => 'Unauthenticated.'], 401);
        }

        return redirect()->guest('login');
    }

and even tried like this

protected function unauthenticated($request, AuthenticationException $exception)
    {
        if ($request->expectsJson()) {
            return response()->json(['error' => 'Unauthenticated.'], 401);
        }

        return redirect('login');
    }

However, once i get to login, i get this error

enter image description here

How can i fix this problem?.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire