user->findIdentityByAccessToken($accessToken); if ($identity === null) { return false; } $account = $identity->getAccount(); if ($account === null) { return false; } if ($account->id !== (int)$accountId) { return false; } if ($account->status !== Account::STATUS_ACTIVE) { return false; } $actualRulesOptional = $params['optionalRules'] ?? false; if (!$actualRulesOptional && !$account->isAgreedWithActualRules()) { return false; } return true; } }