我在用户登录表单中在Laravel中进行多重身份验证错误验证正在运行,但在我的公司登录表单中,错误验证无效。请帮助我,我是Laravel的新人,我只是一名学生。对不起我的英文
这是我的登录代码
0
这是我必须显示错误的表单
public function login(Request $request)
{
$this->validate($request, [
'email' => 'required|email',
'password' => 'required'
]);
if (Auth::guard('company')->attempt(['email' => $request->email, 'password' => $request->password], $request->remember)) {
return redirect()->intended(route('company'));
}
return redirect()->back()->withInput($request->only('email','remember'));
}
答案 0 :(得分:0)
而不是:
return redirect()->back()->withInput($request->only('email','remember'));
使用它:
$errors = new MessageBag(['password' => ['Email and/or password invalid.']]);
return Redirect::back()->withErrors($errors)->withInput(Input::except('password'));
也将此添加到控制器的顶部
use Redirect;
use Illuminate\Support\MessageBag;
use Illuminate\Support\Facades\Input;