Code Duplication    Length = 17-17 lines in 2 locations

app/Auth/PermissionManager.php 1 location

@@ 19-35 (lines=17) @@
16
    /**
17
     * @return bool
18
     */
19
    public function hasAllowedRole($accountId, $action)
20
    {
21
        $actionAllowedRoles = $this->getPermissionItemByAction($action);
22
        $accountRoles = AuthManager::getAccountManager()->getRole($accountId) ?: [];
23
24
        if ($actionAllowedRoles === null) {
25
            return AuthManager::isDefaultAllow();
26
        }
27
28
        foreach ($accountRoles as $role) {
29
            if (in_array($role, $actionAllowedRoles) === true) {
30
                return true;
31
            }
32
        }
33
34
        return false;
35
    }
36
}
37

app/EventListener/Auth/ValidatorListener.php 1 location

@@ 21-37 (lines=17) @@
18
        return true;
19
    }
20
21
    public function isAllowedAccount(ProcInterface $proc, $accountId)
22
    {
23
        $allowdPermissionRoles = AuthManager::getPermissionManager()->getRolesByAction($proc->getName());
24
        $accountRoles = AuthManager::getAccountManager()->getRole($accountId) ?: [];
25
26
        if ($allowdPermissionRoles === null) {
27
            return AuthManager::isDefaultAllow();
28
        }
29
30
        foreach ($accountRoles as $role) {
31
            if (in_array($role, $allowdPermissionRoles)) {
32
                return true;
33
            }
34
        }
35
36
        return false;
37
    }
38
}
39