I want to change to where non-logged in user to be redirected when they try to access pages which required user to be logged in.
I have tried in Exceptions/Handler.php to change it like this
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthenticated.'], 401);
}
return redirect()->guest(route('/users/login'));
}
But when I try to access such page I've got error
InvalidArgumentException Route [/users/login] not defined.
My route in web.php is
Route::get ('/users/login', ['uses' => 'UsersController@getLoginPage', 'before' => 'guest']);
It's also same if I put the home /
Route [/] not defined.
Is this the correct place where this should be done?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire