CheckUserStatus   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 35
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 11 3
1
<?php
2
/*
3
 * This file is part of the Laravel Platfourm package.
4
 *
5
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Longman\Platfourm\Auth\Middleware;
12
13
use Closure;
14
use Longman\Platfourm\Contracts\Auth\AuthUserService as AuthUserServiceContract;
15
16
class CheckUserStatus
17
{
18
19
    /**
20
     * @var \Longman\Platfourm\Contracts\Auth\AuthUserService
21
     */
22
    protected $authService;
23
24
    /**
25
     * CheckUserStatus constructor.
26
     *
27
     * @param \Longman\Platfourm\Contracts\Auth\AuthUserService $authService
28
     */
29
    public function __construct(AuthUserServiceContract $authService)
30
    {
31
        $this->authService = $authService;
32
    }
33
34
    /**
35
     * @param          $request
36
     * @param \Closure $next
37
     * @return \Illuminate\Http\RedirectResponse
38
     */
39
    public function handle($request, Closure $next)
40
    {
41
        if ($this->authService->check() && !$this->authService->user()->canLogin()) {
42
            $this->authService->logout();
43
44
            return redirect('auth/login')
45
                ->with(['error' => 'Your account is disabled']);
46
        }
47
48
        return $next($request);
49
    }
50
}
51