From 703daeb32f538477d06c20a09c635b01be63f847 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Thu, 29 Jan 2026 15:52:34 -0500 Subject: [PATCH] feat: add homepage auto-redirect for logged-in users - Add JavaScript to check for valid JWT token on homepage load - Auto-redirect to /bookshelf if user is already logged in - Shows login/register form if not authenticated - Improves UX by taking logged-in users directly to bookshelf Implementation: - Fetch /api/auth/profile with stored token - On success, redirect to /bookshelf - On failure, silently stay on homepage - Runs on DOMContentLoaded for fast execution --- templates/index.templ | 24 ++++++++++++++++++++++++ templates/index_templ.go | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/templates/index.templ b/templates/index.templ index 1f569ef..71f66c8 100644 --- a/templates/index.templ +++ b/templates/index.templ @@ -240,6 +240,30 @@ templ Index(loggedIn bool) { } + } \ No newline at end of file diff --git a/templates/index_templ.go b/templates/index_templ.go index bf49715..b7b579d 100644 --- a/templates/index_templ.go +++ b/templates/index_templ.go @@ -29,7 +29,7 @@ func Index(loggedIn bool) templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "Bookmann - Home

📚 Bookmann

Your personal ebook management system. Track reading progress, organize your library, and enjoy beautiful themes.

Why Bookmann?

Discover the features that make ebook management effortless

📖

Reading Progress

Track your reading progress across all your ebooks with detailed statistics.

🎨

Beautiful Themes

Choose from 11 stunning themes including Tokyo Night, Dracula, and Catppuccin variants.

Fast & Modern

Built with Go and HTMX for lightning-fast performance and smooth interactions.

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "Bookmann - Home

📚 Bookmann

Your personal ebook management system. Track reading progress, organize your library, and enjoy beautiful themes.

Why Bookmann?

Discover the features that make ebook management effortless

📖

Reading Progress

Track your reading progress across all your ebooks with detailed statistics.

🎨

Beautiful Themes

Choose from 11 stunning themes including Tokyo Night, Dracula, and Catppuccin variants.

Fast & Modern

Built with Go and HTMX for lightning-fast performance and smooth interactions.

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -39,7 +39,7 @@ func Index(loggedIn bool) templ.Component { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err }