2 回答

TA貢獻(xiàn)1858條經(jīng)驗(yàn) 獲得超8個(gè)贊
Authenticate.php根據(jù) 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');
}
在重定向未經(jīng)身份驗(yàn)證的用戶段落下的更多信息。

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超6個(gè)贊
<?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 關(guān)注
- 193 瀏覽
添加回答
舉報(bào)