2 回答

TA贡献1858条经验 获得超8个赞
Authenticate.php根据 Laravel 文档,您只需在中间件中使用要重定向到的 pat 定义此方法:
/**
* Get the path the user should be redirected to.
*
* @param \Illuminate\Http\Request $request
* @return string
*/
protected function redirectTo($request)
{
return route('login');
}
在重定向未经身份验证的用户段落下的更多信息。

TA贡献1829条经验 获得超6个赞
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}
- 2 回答
- 0 关注
- 170 浏览
添加回答
举报