3
When a page that is with the middleware auth
attempts to be accessed by an unauthenticated user, Laravel redirects it to the 'login' route. How to change this so it redirects to another route?
3
When a page that is with the middleware auth
attempts to be accessed by an unauthenticated user, Laravel redirects it to the 'login' route. How to change this so it redirects to another route?
4
Inside your project on the way app/Http/Middleware
there will be a file called Authenticate.php
.
In function redirectTo()
you must change the return line of the function, with the route you want.
For example, you want to change the route of login
for register
.
We will exchange:
protected function redirectTo($request){
if (! $request->expectsJson()) {
return route('login');
}
}
For:
protected function redirectTo($request){
if (! $request->expectsJson()) {
return route('register');
}
}
Browser other questions tagged php laravel laravel-5
You are not signed in. Login or sign up in order to post.