From b54eff648e591d08fcbb3ff7532cf63cbb9d7436 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Fri, 19 Jun 2026 03:56:26 +0530 Subject: [PATCH 1/9] feat: implement runtime authentication handling - Added a new proxy function to manage runtime authentication types and set cookies accordingly. - Introduced runtime authentication configuration to dynamically adjust UI based on the selected auth type. - Updated global styles to hide specific authentication buttons based on the current auth type. - Refactored sign-in button and hero section components to utilize the new runtime authentication logic. - Created a new utility file for runtime authentication configuration and initialization script. --- surfsense_web/app/globals.css | 5 ++ surfsense_web/app/layout.tsx | 15 +++++- .../components/auth/sign-in-button.tsx | 46 ++++++++-------- .../components/homepage/hero-section.tsx | 28 +++++----- surfsense_web/lib/runtime-auth-config.ts | 52 +++++++++++++++++++ surfsense_web/proxy.ts | 24 +++++++++ 6 files changed, 130 insertions(+), 40 deletions(-) create mode 100644 surfsense_web/lib/runtime-auth-config.ts create mode 100644 surfsense_web/proxy.ts diff --git a/surfsense_web/app/globals.css b/surfsense_web/app/globals.css index 3cdb34bff..4a29edfa6 100644 --- a/surfsense_web/app/globals.css +++ b/surfsense_web/app/globals.css @@ -58,6 +58,11 @@ --highlight: oklch(0.852 0.199 91.936); } +html[data-surfsense-auth-type="GOOGLE"] .runtime-auth-local, +html[data-surfsense-auth-type="LOCAL"] .runtime-auth-google { + display: none; +} + .dark { --background: oklch(0.145 0 0); --foreground: oklch(0.985 0 0); diff --git a/surfsense_web/app/layout.tsx b/surfsense_web/app/layout.tsx index 1e9c9eebe..46182f40e 100644 --- a/surfsense_web/app/layout.tsx +++ b/surfsense_web/app/layout.tsx @@ -2,6 +2,7 @@ import type { Metadata, Viewport } from "next"; import "./globals.css"; import { RootProvider } from "fumadocs-ui/provider/next"; import { Roboto } from "next/font/google"; +import Script from "next/script"; import { AnnouncementToastProvider } from "@/components/announcements/AnnouncementToastProvider"; import { DesktopUpdateToast } from "@/components/desktop/desktop-update-toast"; import { GlobalLoadingProvider } from "@/components/providers/GlobalLoadingProvider"; @@ -16,8 +17,13 @@ import { import { ThemeProvider } from "@/components/theme/theme-provider"; import { Toaster } from "@/components/ui/sonner"; import { LocaleProvider } from "@/contexts/LocaleContext"; +import { BUILD_TIME_AUTH_TYPE } from "@/lib/env-config"; import { PlatformProvider } from "@/contexts/platform-context"; import { ReactQueryClientProvider } from "@/lib/query-client/query-client.provider"; +import { + getRuntimeAuthInitScript, + resolveRuntimeAuthUiMode, +} from "@/lib/runtime-auth-config"; import { cn } from "@/lib/utils"; const roboto = Roboto({ @@ -131,8 +137,15 @@ export default function RootLayout({ // Language can be switched dynamically through LanguageSwitcher component // Locale state is managed by LocaleContext and persisted in localStorage return ( - +
+