samedi 2 décembre 2017

How to Get the NotActivatedAccount Error Message (Sentinel with JWTAuth Laravel 5.5)

I am using sentinel and JWTAuth with Laravel 5.5. I am using this package to make it work. Here is the link.

http://ift.tt/2AGhpYU

Everything is working fine. But I want to get the message if account is not activated or ip is blacklisted etc.

I am using this code in SentinelAuthAdapter.php.

public function byCredentials(array $credentials = []){
   try{
      //$remember_me = false;
      $user = Sentinel::authenticate($credentials);
      return $user instanceof UserInterface;
   }catch(ThrottlingException $e){
      return false;
   }catch(NotActivatedException $e){
       return response()->json(['errors' => "Your account is not activated yet."]);
}}

If I return false then works with this message in AuthenticateController.php

return response()->json(['error' => 'invalid_credentials'], 401);

But I am getting an error if I want to return any message from byCredentials Exception. How can I show exception message from sentinel?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire