Created
March 10, 2018 00:35
-
-
Save brunokunace/292974ffe2a360a5ac72b459a4647fe6 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