CommandAuthorizer.php 896 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php


namespace Source\UseCases\Door\Access\Authorizers;


use Carbon\Carbon;
use Source\Entities\User;
use Source\Authorization\Permissions;
use Source\Authorization\ApiAuthorizer;
use Source\UseCases\Door\Access\AccessAuthorizer;

class CommandAuthorizer implements AccessAuthorizer
{
    /**
     * @var \Source\Authorization\ApiAuthorizer
     */
    protected ApiAuthorizer $authorizer;

    public function __construct(ApiAuthorizer $authorizer)
    {
        $this->authorizer = $authorizer;
    }

    /**
     * @inheritDoc
     */
    public function check(?User $user, Carbon $date, string $doorId, string $doorcode, ?string $commandString): int
    {
        if ($commandString) {
            if ($this->authorizer->allowsOne([Permissions::DOOR_COMMANDER, Permissions::MANAGE_DOORS])) {

            }
            return self::DENY;
        }
        return self::CONTINUE;
    }
}