We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 3 |
| Paths | 4 |
| Total Lines | 21 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | public function authenticate(Request $request) |
||
| 15 | { |
||
| 16 | // grab credentials from the request |
||
| 17 | $credentials = $request->only('email', 'password'); |
||
| 18 | |||
| 19 | try { |
||
| 20 | // attempt to verify the credentials and create a token for the user |
||
| 21 | if (! $token = JWTAuth::attempt($credentials)) { |
||
| 22 | return response()->json(['error' => 'invalid_credentials'], 401); |
||
| 23 | } |
||
| 24 | } catch (JWTException $e) { |
||
| 25 | // something went wrong whilst attempting to encode the token |
||
| 26 | return response()->json(['error' => 'could_not_create_token'], 500); |
||
| 27 | } |
||
| 28 | |||
| 29 | // all good so return the token |
||
| 30 | return response()->json([ |
||
| 31 | 'access_token' => $token, |
||
| 32 | 'token_type' => 'bearer' |
||
| 33 | ]); |
||
| 34 | } |
||
| 35 | } |
||
| 36 |