Repository: goauthentik/authentik

Issue:
Fixed light/dark theme setting
Hello, is it possible to set the dark and light theme fixed? With the OS autodetection I have otherwise problems with my different logos that I use in my Tenants settings. Light logos are not visible to users on light platforms, dark logos are not visible to users on dark platforms.
Thanks in advanced
pupazze


Discussion:

Resolving patch:
diff --git a/authentik/tenants/api.py b/authentik/tenants/api.py
--- a/authentik/tenants/api.py
+++ b/authentik/tenants/api.py
@@ -1,10 +1,11 @@
 """Serializer for tenant models"""
 from typing import Any
 
+from django.db import models
 from drf_spectacular.utils import extend_schema
 from rest_framework.decorators import action
 from rest_framework.exceptions import ValidationError
-from rest_framework.fields import CharField, ListField
+from rest_framework.fields import CharField, ChoiceField, ListField
 from rest_framework.filters import OrderingFilter, SearchFilter
 from rest_framework.permissions import AllowAny
 from rest_framework.request import Request
@@ -59,6 +60,14 @@ class Meta:
         ]
 
 
+class Themes(models.TextChoices):
+    """Themes"""
+
+    AUTOMATIC = "automatic"
+    LIGHT = "light"
+    DARK = "dark"
+
+
 class CurrentTenantSerializer(PassiveSerializer):
     """Partial tenant information for styling"""
 
@@ -71,6 +80,12 @@ class CurrentTenantSerializer(PassiveSerializer):
         read_only=True,
         default=CONFIG.y("footer_links", []),
     )
+    ui_theme = ChoiceField(
+        choices=Themes.choices,
+        source="attributes.settings.theme.base",
+        default=Themes.AUTOMATIC,
+        read_only=True,
+    )
 
     flow_authentication = CharField(source="flow_authentication.slug", required=False)
     flow_invalidation = CharField(source="flow_invalidation.slug", required=False)


Test patch:
diff --git a/authentik/tenants/tests.py b/authentik/tenants/tests.py
--- a/authentik/tenants/tests.py
+++ b/authentik/tenants/tests.py
@@ -7,6 +7,7 @@
 from authentik.events.models import Event, EventAction
 from authentik.lib.config import CONFIG
 from authentik.lib.utils.time import timedelta_from_string
+from authentik.tenants.api import Themes
 from authentik.tenants.models import Tenant
 
 
@@ -24,6 +25,7 @@ def test_current_tenant(self):
                 "branding_title": "authentik",
                 "matched_domain": tenant.domain,
                 "ui_footer_links": CONFIG.y("footer_links"),
+                "ui_theme": Themes.AUTOMATIC,
                 "default_locale": "",
             },
         )
@@ -42,6 +44,7 @@ def test_tenant_subdomain(self):
                 "branding_title": "custom",
                 "matched_domain": "bar.baz",
                 "ui_footer_links": CONFIG.y("footer_links"),
+                "ui_theme": Themes.AUTOMATIC,
                 "default_locale": "",
             },
         )
@@ -57,6 +60,7 @@ def test_fallback(self):
                 "branding_title": "authentik",
                 "matched_domain": "fallback",
                 "ui_footer_links": CONFIG.y("footer_links"),
+                "ui_theme": Themes.AUTOMATIC,
                 "default_locale": "",
             },
         )