summaryrefslogtreecommitdiff
path: root/Biz
diff options
context:
space:
mode:
Diffstat (limited to 'Biz')
-rw-r--r--Biz/PodcastItLater/UI.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/Biz/PodcastItLater/UI.py b/Biz/PodcastItLater/UI.py
index 4844d67..8959d4e 100644
--- a/Biz/PodcastItLater/UI.py
+++ b/Biz/PodcastItLater/UI.py
@@ -127,6 +127,16 @@ def create_bootstrap_js() -> html.script:
)
+def is_admin(user: dict[str, typing.Any] | None) -> bool:
+ """Check if user is an admin based on email whitelist."""
+ if not user:
+ return False
+ admin_emails = ["ben@bensima.com", "demo@example.com"]
+ return user.get("email", "").lower() in [
+ email.lower() for email in admin_emails
+ ]
+
+
class PageLayoutAttrs(Attrs):
"""Attributes for PageLayout component."""
@@ -144,8 +154,6 @@ class PageLayout(Component[AnyChildren, PageLayoutAttrs]):
current_page: str,
) -> html.nav:
"""Render navigation bar."""
- # Import here to avoid circular dependency
- import Biz.PodcastItLater.Core as Core # noqa: PLC0415 # type: ignore[import-untyped]
def is_active(page: str) -> bool:
return current_page == page
@@ -258,7 +266,7 @@ class PageLayout(Component[AnyChildren, PageLayoutAttrs]):
),
classes=["nav-item", "dropdown"],
)
- if user and Core.is_admin(user)
+ if user and is_admin(user)
else html.span(),
classes=["navbar-nav"],
),