我在我的项目中使用模块
App ->
Modules ->
Admin ->
Http ->
controller
middleware
request
我如何在此中间件中使用身份验证和重定向身份验证文件 在此中间件中验证文件或重定向验证文件
验证.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
public function handle($request, Closure $next)
{
if ($this->auth->check()) {
// return redirect('/home');
return redirect('admin/dashbord');
}
return $next($request);
}
如何解决这个问题?
最佳答案
如 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
:
protected $loginPath = '/login';
在您的情况下,您将使用 '/admin'
而不是 '/login'
。
关于php - 如何更改 Laravel 5 中的默认登录 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34040432/