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 關注
- 203 瀏覽
添加回答
舉報
