Completed
Push — master ( cb5a9c...81e444 )
by ARCANEDEV
03:29
created

ApiController::check()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
ccs 0
cts 11
cp 0
rs 9.4286
cc 2
eloc 7
nc 2
nop 0
crap 6
1
<?php namespace Arcanesoft\Auth\Http\Controllers\Front;
2
3
use Arcanesoft\Auth\Bases\Controller;
4
use Illuminate\Contracts\Auth\Guard;
5
6
/**
7
 * Class     ApiController
8
 *
9
 * @package  Arcanesoft\Auth\Http\Controllers\Front
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class ApiController extends Controller
13
{
14
    /* ------------------------------------------------------------------------------------------------
15
     |  Properties
16
     | ------------------------------------------------------------------------------------------------
17
     */
18
    /**
19
     * @var \Illuminate\Contracts\Auth\Guard
20
     */
21
    private $auth;
22
23
    /* ------------------------------------------------------------------------------------------------
24
     |  Constructor
25
     | ------------------------------------------------------------------------------------------------
26
     */
27
    /**
28
     * ApiController constructor.
29
     *
30
     * @param  \Illuminate\Contracts\Auth\Guard  $auth
31
     */
32
    public function __construct(Guard $auth)
33
    {
34
        parent::__construct();
35
36
        $this->auth = $auth;
37
    }
38
39
    /* ------------------------------------------------------------------------------------------------
40
     |  Main Functions
41
     | ------------------------------------------------------------------------------------------------
42
     */
43
    public function check()
44
    {
45
        self::onlyAjax();
46
47
        if ( ! $this->auth->check()) {
48
            abort(404, 'Page not found');
49
        }
50
51
        return [
52
            'success' => true,
53
            'message' => 'User authenticated.',
54
        ];
55
    }
56
}
57