Completed
Push — 2.0 ( 2d1915 )
by Nicolas
14:43
created

LoggedInMiddleware::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 2
1
<?php namespace Modules\User\Http\Middleware;
2
3
use Modules\Core\Contracts\Authentication;
4
5
class LoggedInMiddleware
6
{
7
    /**
8
     * @var Authentication
9
     */
10
    private $auth;
11
12
    public function __construct(Authentication $auth)
13
    {
14
        $this->auth = $auth;
15
    }
16
17
    /**
18
     * Handle an incoming request.
19
     * @param  \Illuminate\Http\Request $request
20
     * @param  \Closure $next
21
     * @return mixed
22
     */
23
    public function handle($request, \Closure $next)
24
    {
25
        if (! $this->auth->check()) {
26
            return redirect()->guest('auth/login');
27
        }
28
29
        return $next($request);
30
    }
31
}
32