Skip to content

Server-side render login/logout nav based on session state#155

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/remove-sidebar-flickering-logic
Draft

Server-side render login/logout nav based on session state#155
Copilot wants to merge 3 commits intomainfrom
copilot/remove-sidebar-flickering-logic

Conversation

Copy link
Contributor

Copilot AI commented Feb 26, 2026

Showing a Logout link to unauthenticated users is wrong. The previous flickering fix always rendered Logout for everyone since hiding/showing via JS was removed.

Approach

Render the correct nav-bottom HTML at the server level using auth.TrySession(r) — no JS toggling, no flicker.

  • Template: Replaced hardcoded nav-bottom with a %s placeholder
  • Two nav-bottom variants:
    • navBottomLogin — renders a Login link
    • navBottomAccount — renders username div + Account + Logout
  • RenderHTMLForRequest: Checks session, injects the correct variant
  • RenderHTML (no request context): Defaults to navBottomLogin
  • Account handler: Upgraded from RenderHTMLRenderHTMLForRequest
  • Mail handler: All three RenderHTML calls upgraded to RenderHTMLForRequest
func RenderHTMLForRequest(title, desc, html string, r *http.Request) string {
    lang := GetUserLanguage(r)
    _, acc := auth.TrySession(r)
    if acc != nil {
        return RenderHTMLWithLang(title, desc, html, lang, navBottomAccount)
    }
    return RenderHTMLWithLang(title, desc, html, lang, navBottomLogin)
}

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: asim <17530+asim@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove sidebar link hiding logic during loading Remove sidebar flickering by eliminating auth-based nav visibility toggling Feb 26, 2026
…sion

Co-authored-by: asim <17530+asim@users.noreply.github.com>
Copilot AI changed the title Remove sidebar flickering by eliminating auth-based nav visibility toggling Server-side render login/logout nav based on session state Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants