Php 如何在使用Auth::trunt()登录Laravel 5.3应用程序时显示特定错误

Php 如何在使用Auth::trunt()登录Laravel 5.3应用程序时显示特定错误,php,laravel,authentication,laravel-5,Php,Laravel,Authentication,Laravel 5,我的问题有点类似于,但我在登录时没有收到任何错误。我正在使用Auth::trunt()在我的应用程序中记录用户,但如果身份验证失败,并且没有提供电子邮件或密码是否错误的线索,则返回false。我需要知道的是,在这种情况下是否有可能得到具体的错误。我已经查阅了所有的文档,但到目前为止还没有提供答案。我知道我可以创建一个消息包并将其与自定义消息一起返回,但我希望返回特定消息,就像验证程序那样。大概是这样的: [ 'password' => 'This password is incor

我的问题有点类似于,但我在登录时没有收到任何错误。我正在使用
Auth::trunt()
在我的应用程序中记录用户,但如果身份验证失败,并且没有提供电子邮件或密码是否错误的线索,则返回
false
。我需要知道的是,在这种情况下是否有可能得到具体的错误。我已经查阅了所有的文档,但到目前为止还没有提供答案。我知道我可以创建一个消息包并将其与自定义消息一起返回,但我希望返回特定消息,就像
验证程序那样。大概是这样的:

[
    'password' => 'This password is incorrect'
]


谢谢

你需要自己去抓

$user = User::where('email', $request->email)->first();
if ( !$user ) {
    return redirect()->back()->withErrors([
        'email' => 'This email doesn\'t exist'
    ]);
}

if( Auth::attemp(['email' => $user->email, 'password' => $request->password]) ) {
    //Logging successful
    return redirect()->to('dashboard');
}

//if you get to this line, login failed
return redirect()->back()->withErrors([
    'password' => 'This password is incorrect'
]);
$user = User::where('email', $request->email)->first();
if ( !$user ) {
    return redirect()->back()->withErrors([
        'email' => 'This email doesn\'t exist'
    ]);
}

if( Auth::attemp(['email' => $user->email, 'password' => $request->password]) ) {
    //Logging successful
    return redirect()->to('dashboard');
}

//if you get to this line, login failed
return redirect()->back()->withErrors([
    'password' => 'This password is incorrect'
]);