如果用户的会话已过期,我正在尝试将用户重定向回登录页面。我正在使用 Laravel 5.5。我已经编辑了我的RedirectIfAuthenticated
文件中包含以下代码handle
功能:
if (!Auth::check()) {
return redirect()->route('login', ['account' => 'demo']);
}
当我这样做时,我收到以下错误消息:
缺少 [路由:登录] [URI:/] 所需的参数。
My login
路由位于子域路由组内,这就是为什么我要传递account
范围。这是我的代码的一部分web.php
// Subdomain routing
Route::domain('{account}.ems.dev')->group(function () {
Route::get('/', 'LoginController@show')->name('login');
}
这是我的LoginController@show
code:
/*
* Show the login form
*/
public function show($account) {
// Validate this is a valid subdomain
$organization = Organization::where('subdomain', $account)->first();
if ($organization) {
return view('login');
} else {
return 'This account does not exist.';
}
}
我尝试过的一切都不起作用。即使我传递了所需的参数,我仍然收到完全相同的错误消息。
更新#1
错误页面截图:
更新#2
经过一番挖掘之后Whoops!错误页面,我看到这个,protected function unauthenticated
是什么导致了这个问题:
如何重写此函数以添加缺少的参数?