如何更改 Laravel 5 中的默认登录 URL?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34040432/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change default login URL in Laravel 5?
提问by Gurpreet Singh
i use module in my project
我在我的项目中使用模块
App ->
Modules ->
Admin ->
Http ->
controller
middleware
request
how i use authenticate and redirect auth file in this middleware authenticate file or redirectauth file in this middleware
我如何在此中间件中使用身份验证和重定向身份验证文件身份验证文件或此中间件中的重定向身份验证文件
authenticate.php
验证文件
public function handle($request, Closure $next)
{
if ($this->auth->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
// return redirect()->guest('auth/login');
return redirect()->guest('admin');
}
}
return $next($request);
}
redirectauthenticate.php
重定向验证.php
public function handle($request, Closure $next)
{
if ($this->auth->check()) {
// return redirect('/home');
return redirect('admin/dashbord');
}
return $next($request);
}
how i solve this problem?
我如何解决这个问题?
采纳答案by Rubens Mariuzzo
As it appear in the docs:
正如它出现在文档中:
When a user is not successfully authenticated, they will be redirected to the
/auth/login
URI. You can customize the failed post-authentication redirect location by defining aloginPath
property on theAuthController
:
当用户未成功通过身份验证时,他们将被重定向到
/auth/login
URI。您可以通过loginPath
在 上定义一个属性来自定义失败的身份验证后重定向位置AuthController
:
protected $loginPath = '/login';
In your case you will use '/admin'
instead of '/login'
.
在您的情况下,您将使用'/admin'
而不是'/login'
.