When authenticating a user in Laravel 4, the Auth::attemp(..)
method returns false if the authentication failed. Is there a way to narrow down why it failed so I can indicate to my users whether, for example, it was the password vs their username that was in error?
Thanks
No direct one, but you can always:
if ( ! User::where('email', Input::get('email'))->first())
{
/// email's wrong
}
else
{
if ( ! Auth::attempt(['email' => Input::get('email'), 'password' => Input::get('password')])
{
/// password's wrong
}
}
If you need to give this information to your user, there's nothing wrong in doing this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.