Completed
Push — master ( 14152b...08794d )
by wen
10:50
created

Authenticate::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace Sco\Admin\Http\Middleware;
4
5
use Closure;
6
use Auth;
7
use Sco\Admin\Exceptions\AuthenticationException;
8
9
class Authenticate
10
{
11
12
    /**
13
     * Handle an incoming request.
14
     *
15
     * @param  \Illuminate\Http\Request $request
16
     * @param  \Closure                 $next
17
     *
18
     * @return mixed
19
     * @throws \Sco\Admin\Exceptions\AuthenticationException
20
     */
21
    public function handle($request, Closure $next)
22
    {
23
        $this->authenticate();
24
25
        return $next($request);
26
    }
27
28
    /**
29
     * Determine if the user is logged in to any of the given guards.
30
     *
31
     * @return mixed
32
     * @throws \Sco\Admin\Exceptions\AuthenticationException
33
     */
34
    protected function authenticate()
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
35
    {
36
        if (Auth::check()) {
37
            return Auth::user();
38
        }
39
40
        throw new AuthenticationException();
41
    }
42
}
43