当我尝试提交登录表单时,它会以MethodNotAllowedHttpException
错误且没有消息的方式进入注销路径
// this is my route
Route::get('/',function(){return view('users.home');});
Route::get('register', 'RegisterController@showRegistrationForm')->name('showRegister');
Route::post('register', 'RegisterController@register')->name('Register');
Route::get('login', 'LoginController@showLoginForm')->name('showLogin');
Route::post('login', 'LoginController@login')->name('login');
这是我的登录和注销控制器
public function login(loginRequest $request )
{
if ( Auth()->attempt(['email' => $request->Username, 'password' => $request->Password], $request->remember) ) {
return redirect()->intended( url('dashboard') );
}// Authentication failed, redirect back to the login form
return redirect($this->redirect);
}
/**
* Log the user out of the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function logout(Request $request)
{
Auth::guard()->logout();
$request->session()->flush();
return redirect()->guest(route('showLogin'));
}
答案 0 :(得分:0)
代替redirect($this->redirect)
使用Redirect::back()
return Redirect::back()->withErrors(['msg', 'The Message']);
以及您的登录控制器功能
public function login(loginRequest $request )
{
if ( Auth()->attempt(['email' => $request->Username, 'password' => $request->Password], $request->remember) ) {
return redirect('/dashboard');
}// Authentication failed, redirect back to the login form
return Redirect::back()->withErrors(['msg', 'The Message']);
}
在您的视图内调用此
@if($errors->any())
<h4>{{$errors->first()}}</h4>
@endif
答案 1 :(得分:0)
登录控制器中的重定向错误
"antd/es/button"