So I just set up a L5.3 project and I want my login route to be at "/signin".
My web.php
routes file looks like this:
\Route::get('/signin', 'Auth\LoginController@showLoginForm');
\Route::post('/signin', 'Auth\LoginController@login');
When I visit a route with the $this->middleware('auth');
middleware it automatically redirects me to /login
- but I want to get redirected to /signin
.
I searched through the project but couldn't find the place where this gets set!
Thanks!
It happens at https://github.com/laravel/framework/blob/5.3/src/Illuminate/Auth/Middleware/Authenticate.php, if you copy and paste you can edit it.
Actually it was alot easier!
I just had to change the redirect in app/Exceptions/Handler
:
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthenticated.'], 401);
}
return redirect()->guest(action('Auth\LoginController@showLoginForm'));
}
not working
Most helpful comment
Actually it was alot easier!
I just had to change the redirect in
app/Exceptions/Handler
: