Tuesday, March 14, 2017

How to display specific errors when loggin in in a Laravel 5.3 app with the Auth::attempt()

My question is somewhat similar to this but I'm not getting any error when logging in. I'm using Auth::attempt() to log users in my app but it returns false if authentication fails without giving a clue to whether was the email or the password that were incorrect. What I need to know is if it is possible to get specific errors in this situation. I've been all over the documentation but it failed to provide answers so far. I know that I can create a message bag and return it with a custom message but what I would like is to return specific message much like the validatordoes. Something like this:

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

or

[
    'email' => 'This email doesn\'t exist'
]

Thanks!



via António Quadrado

Advertisement