diff --git a/api.php b/api.php index b616dc8..28e5f7d 100644 --- a/api.php +++ b/api.php @@ -1424,18 +1424,30 @@ switch ($action) { } // Hae allekirjoitukset (oletus generoituna jos omaa ei ole) $userSignatures = $u ? buildSignaturesWithDefaults($u, $u['companies'] ?? []) : []; - // Brändäystiedot domain-pohjaisesti (sama kuin branding-endpoint) - $host = strtolower(explode(':', $_SERVER['HTTP_HOST'] ?? '')[0]); - $branding = dbGetBranding($host); - // Aktiivisen yrityksen enabled_modules + // Brändäystiedot aktiivisen yrityksen mukaan (ei domain-pohjainen) $activeCompanyId = $_SESSION['company_id'] ?? ''; + $branding = null; $enabledModules = []; foreach ($allCompanies as $comp) { if ($comp['id'] === $activeCompanyId) { + $logoUrl = !empty($comp['logo_file']) + ? "api.php?action=company_logo&company_id=" . urlencode($comp['id']) + : ''; + $branding = [ + 'found' => true, + 'company_id' => $comp['id'], + 'nimi' => $comp['nimi'], + 'primary_color' => $comp['primary_color'] ?? '#0f3460', + 'subtitle' => $comp['subtitle'] ?? '', + 'logo_url' => $logoUrl, + ]; $enabledModules = $comp['enabled_modules'] ?? []; break; } } + if (!$branding) { + $branding = ['found' => false, 'nimi' => 'Noxus Intra', 'primary_color' => '#0f3460', 'subtitle' => 'Hallintapaneeli', 'logo_url' => '']; + } echo json_encode([ 'authenticated' => true, 'user_id' => $_SESSION['user_id'],