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

AuthorizationController::checkAdminAccess()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace flipbox\patron\cp\controllers;
4
5
use Craft;
6
use flipbox\patron\actions\authorization\Authorize;
7
8
class AuthorizationController extends AbstractController
9
{
10
    /**
11
     * @inheritdoc
12
     */
13
    protected function verbs(): array
14
    {
15
        return [
16
            'authorize' => ['get']
17
        ];
18
    }
19
20
    /**
21
     * @param int|null $id
22
     * @return mixed
23
     * @throws \yii\base\InvalidConfigException
24
     */
25
    public function actionAuthorize(int $id = null)
26
    {
27
        if (null === $id) {
28
            $id = (int)Craft::$app->getRequest()->getBodyParam('id');
29
        }
30
31
        $action = Craft::createObject([
32
            'class' => Authorize::class,
33
            'checkAccess' => [$this, 'checkAdminAccess']
34
        ], [
35
            'authorize',
36
            $this
37
        ]);
38
39
        return $action->runWithParams([
40
            'id' => $id
41
        ]);
42
    }
43
44
    /**
45
     * @inheritDoc
46
     */
47
    public function checkAdminAccess(): bool
48
    {
49
        $this->requireAdmin(false);
50
        return true;
51
    }
52
}
53