Fix SuperAdmin access sync for tenant domains and persist flags locally.

Expand www/admin domain aliases when resolving program-settings, and save owned keys to local settings after a successful refresh so menu flags like customer_special_pricing stay applied.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-29 23:35:37 +03:30
co-authored by Cursor
parent 63195718a2
commit 9f6203075a
2 changed files with 74 additions and 6 deletions
@@ -309,18 +309,48 @@ class SuperAdminProgramSettingsClient
$out = [];
foreach ($candidates as $host) {
if ($host === '' || in_array($host, $out, true)) {
continue;
foreach ($this->expandDomainAliases($host) as $alias) {
if ($alias === '' || in_array($alias, $out, true)) {
continue;
}
if (in_array($alias, ['localhost', '127.0.0.1', '::1'], true)) {
continue;
}
$out[] = $alias;
}
if (in_array($host, ['localhost', '127.0.0.1', '::1'], true)) {
continue;
}
$out[] = $host;
}
return $out;
}
/**
* admin.example.com / www.example.com → example.com هم امتحان شود.
*
* @return list<string>
*/
private function expandDomainAliases(string $host): array
{
$host = $this->normalizeHost($host);
if ($host === '') {
return [];
}
$aliases = [$host];
foreach (['www.', 'admin.', 'panel.', 'app.'] as $prefix) {
if (str_starts_with($host, $prefix)) {
$bare = substr($host, strlen($prefix));
if ($bare !== '') {
$aliases[] = $bare;
}
}
}
if (! str_starts_with($host, 'www.')) {
$aliases[] = 'www.'.$host;
}
return array_values(array_unique($aliases));
}
private function normalizeHost(string $value): string
{
$host = strtolower(trim($value));