Created
February 16, 2018 01:16
-
-
Save brunokunace/8aa4644500b5f8569984e890977a4797 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function authenticate() | |
| { | |
| $credentials = request()->only('cpf', 'password'); | |
| try | |
| { | |
| $token = JWTAuth::attempt($credentials); | |
| if(!$token){ | |
| $credentials['email'] = $credentials['cpf']; | |
| unset($credentials['cpf']); | |
| try | |
| { | |
| $token = JWTAuth::attempt($credentials); | |
| if(!$token){ | |
| return response()->json(['error' => 'Dados Incorretos'], 401); | |
| } | |
| }catch (JWTException $e) | |
| { | |
| return response()->json(['error' => 'something_wrong'],500); | |
| } | |
| } | |
| }catch (JWTException $e) | |
| { | |
| return response()->json(['error' => 'something_wrong'],500); | |
| } | |
| return response()->json(['token' => $token], 200); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment