samedi 25 juin 2016

Overriding Login Error Messages

I have an AuthController, where I have extended the getCredentials method so the user needs to be both existant and active to be able to login. This is the method:

protected function getCredentials(Request $request) {
  $credentials = $request->only($this->loginUsername(), 'password');
  return array_add($credentials, 'status', '1');
}

I would also like the failed login messages to be different, depending on whether or not the user is active, so the user knows if he is failing his username / password, or just because he hasn't activated his account yet.

I could override the login method of the AuthenticatesUser trait, but it seems overkill to duplicate all the logic just to change that.

Can I extend the sendFailedLoginResponse method to make some sort of validation there, based on the previous Auth::guard->attempt() call? I mean, does that method leave any information behind that allows me to know, after the call has been made, what made the attempt return false?

Or how would I approach this, without having to override a method completely just to make a simple validation?

Thank you.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/28TCH8r
via IFTTT

Aucun commentaire:

Enregistrer un commentaire