forked from fa/breadcrumb-the-shire
feat(helpdesk): refactor multi-tenant BC settings and risk radar improvements
Restructure helpdesk tenant settings into per-connection config with improved token handling. Update risk radar data endpoint and UI. Clean up ImageUploadTrait and update architecture contract tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -32,11 +32,13 @@ class HelpdeskTokenRepository
|
||||
(string) $tenantId
|
||||
);
|
||||
|
||||
if (!is_array($result) || !isset($result['access_token_encrypted'])) {
|
||||
// MintyPHP wraps selectOne results in ['table_name' => [...]]
|
||||
$row = is_array($result) ? ($result['helpdesk_oauth_token_cache'] ?? $result) : null;
|
||||
if (!is_array($row) || !isset($row['access_token_encrypted'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$encrypted = trim((string) $result['access_token_encrypted']);
|
||||
$encrypted = trim((string) $row['access_token_encrypted']);
|
||||
if ($encrypted === '') {
|
||||
return null;
|
||||
}
|
||||
@@ -49,13 +51,28 @@ class HelpdeskTokenRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all cached tokens (used when BC config changes to prevent stale credentials).
|
||||
* Delete all cached tokens (used when global BC config changes).
|
||||
*/
|
||||
public function deleteAll(): bool
|
||||
{
|
||||
return (bool) DB::delete('DELETE FROM helpdesk_oauth_token_cache WHERE 1=1');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete cached tokens for a specific tenant (used when tenant config changes).
|
||||
*/
|
||||
public function deleteByTenantId(int $tenantId): bool
|
||||
{
|
||||
if ($tenantId <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) DB::delete(
|
||||
'DELETE FROM helpdesk_oauth_token_cache WHERE tenant_id = ?',
|
||||
(string) $tenantId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a new token in the cache (encrypted, tenant-scoped).
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user