Completed
Push — master ( 394e09...9f8e0d )
by Igor
05:41 queued 01:11
created

AuthController::refresh()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Http\Controllers\Auth;
4
5
use JWTAuth;
6
use Exception;
7
use App\Http\Controllers\Controller;
8
use Illuminate\Http\Request;
9
10
class AuthController extends Controller
11
{
12 2
    public function authenticate(Request $request)
13
    {
14
        $credentials = [
15 2
            'email' => $request->json('login'),
16 2
            'password' => $request->json('password'),
17
        ];
18
19
        try {
20 2
            if (! $token = JWTAuth::attempt($credentials)) {
21 2
                return response()->json(['error' => 'invalid_credentials'], 401);
22
            }
23
        } catch (JWTException $e) {
0 ignored issues
show
Bug introduced by
The type App\Http\Controllers\Auth\JWTException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
            return response()->json(['error' => 'could_not_create_token'], 500);
25
        }
26
27 1
        return response()->json(compact('token'));
28
    }
29
}
30