Completed
Push — master ( 521250...f55e31 )
by Manuel
04:22
created

Handler::unauthenticated()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 0
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 2
crap 6
1
<?php
2
3
namespace PiFinder\Exceptions;
4
5
use Exception;
6
use Illuminate\Auth\AuthenticationException;
7
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
8
9
class Handler extends ExceptionHandler
10
{
11
    /**
12
     * A list of the exception types that should not be reported.
13
     *
14
     * @var array
15
     */
16
    protected $dontReport = [
17
        \Illuminate\Auth\AuthenticationException::class,
18
        \Illuminate\Auth\Access\AuthorizationException::class,
19
        \Symfony\Component\HttpKernel\Exception\HttpException::class,
20
        \Illuminate\Database\Eloquent\ModelNotFoundException::class,
21
        \Illuminate\Session\TokenMismatchException::class,
22
        \Illuminate\Validation\ValidationException::class,
23
    ];
24
25
    /**
26
     * Report or log an exception.
27
     *
28
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
29
     *
30
     * @param \Exception $exception
31
     *
32
     * @return void
33
     */
34
    public function report(Exception $exception)
35
    {
36
        parent::report($exception);
37
    }
38
39
    /**
40
     * Render an exception into an HTTP response.
41
     *
42
     * @param \Illuminate\Http\Request $request
43
     * @param \Exception               $exception
44
     *
45
     * @return \Illuminate\Http\Response
46
     */
47
    public function render($request, Exception $exception)
48
    {
49
        return parent::render($request, $exception);
50
    }
51
52
    /**
53
     * Convert an authentication exception into an unauthenticated response.
54
     *
55
     * @param \Illuminate\Http\Request                 $request
56
     * @param \Illuminate\Auth\AuthenticationException $exception
57
     *
58
     * @return \Illuminate\Http\Response
59
     */
60
    protected function unauthenticated($request, AuthenticationException $exception)
0 ignored issues
show
Unused Code introduced by
The parameter $exception is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
61
    {
62
        if ($request->expectsJson()) {
63
            return response()->json(['error' => 'Unauthenticated.'], 401);
64
        }
65
66
        return redirect()->guest('login');
67
    }
68
}
69