Completed
Push — master ( 424357...d1d6a1 )
by Nate
24:35 queued 09:39
created

AuthorizationController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 59
ccs 0
cts 40
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A behaviors() 0 21 2
A actions() 0 9 1
A verbs() 0 6 1
A checkCallbackAccess() 0 5 1
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/patron/license
6
 * @link       https://www.flipboxfactory.com/software/patron/
7
 */
8
9
namespace flipbox\patron\controllers;
10
11
use craft\helpers\ArrayHelper;
12
use flipbox\craft\ember\controllers\AbstractController;
13
use flipbox\craft\ember\filters\CallableFilter;
14
use flipbox\patron\actions\authorization\Callback;
15
use flipbox\patron\Patron;
16
17
/**
18
 * @author Flipbox Factory <[email protected]>
19
 * @since 1.0.0
20
 */
21
class AuthorizationController extends AbstractController
22
{
23
    /**
24
     * @inheritdoc
25
     */
26
    public function behaviors()
27
    {
28
        return ArrayHelper::merge(
29
            parent::behaviors(),
30
            [
31
                'redirect' => [
32
                    'class' => CallableFilter::class,
33
                    'actions' => [
34
                        'callback' => function () {
35
                            $redirectUrl = Patron::getInstance()->getSession()->getRedirectUrl();
36
                            Patron::getInstance()->getSession()->removeAll();
37
38
                            if ($redirectUrl) {
39
                                return $this->redirect($redirectUrl);
40
                            }
41
                        }
42
                    ]
43
                ]
44
            ]
45
        );
46
    }
47
48
    /**
49
     * @inheritdoc
50
     */
51
    protected function verbs(): array
52
    {
53
        return [
54
            'callback' => ['get']
55
        ];
56
    }
57
58
    /**
59
     * @inheritdoc
60
     */
61
    public function actions()
62
    {
63
        return [
64
            'callback' => [
65
                'class' => Callback::class,
66
                'checkAccess' => [$this, 'checkCallbackAccess']
67
            ]
68
        ];
69
    }
70
71
    /**
72
     * @return bool
73
     */
74
    public function checkCallbackAccess()
75
    {
76
        $this->requireLogin();
77
        return true;
78
    }
79
}
80