Skip to content

Commit db415fb

Browse files
tastybentoclaude
andcommitted
Add a Login button to the header for logged-out users
The header only rendered the user menu once signed in, so there was no login affordance anywhere in the nav — the only "Login with Discord" buttons lived on /account, /admin and /submit, reachable only by typing the path manually. Add a Discord-styled Login button (desktop header + mobile drawer) shown only when user === null, linking to the OAuth flow with a return path of the current page (or /account from the landing page). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent a56661a commit db415fb

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

src/web/components/Navigation.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ export default function Navigation() {
112112
const showAdminTab = isAdmin || canAuthorBlog;
113113
const TABS: Tab[] = showAdminTab ? [...BASE_TABS, ADMIN_TAB] : BASE_TABS;
114114

115+
// After login Discord redirects back to wherever the user was, except on the
116+
// landing page where /account is the more useful confirmation landing spot.
117+
const loginReturn =
118+
location.pathname === '/' ? '/account' : location.pathname + location.search;
119+
const loginHref = `/api/auth/discord/login?return=${encodeURIComponent(loginReturn)}`;
120+
115121
// The header sits on top of the dark hero on `/` and stays transparent
116122
// until the user scrolls past it. On every other route it's solid paper.
117123
// The blog subdomain serves BlogList at `/` instead of Landing, so on
@@ -414,6 +420,22 @@ export default function Navigation() {
414420
)}
415421
</div>
416422
)}
423+
{user === null && (
424+
<a
425+
href={loginHref}
426+
className="bb-btn bb-btn-discord"
427+
style={{
428+
padding: '8px 12px',
429+
fontSize: 13,
430+
display: 'inline-flex',
431+
alignItems: 'center',
432+
gap: 8,
433+
}}
434+
>
435+
<FontAwesomeIcon icon={faDiscord} />
436+
Login
437+
</a>
438+
)}
417439
</div>
418440

419441
{/* Mobile hamburger */}
@@ -571,6 +593,25 @@ export default function Navigation() {
571593
</button>
572594
</div>
573595
)}
596+
{user === null && (
597+
<a
598+
href={loginHref}
599+
onClick={() => setMobileOpen(false)}
600+
className="bb-btn bb-btn-discord"
601+
style={{
602+
marginTop: 16,
603+
width: '100%',
604+
fontSize: 14,
605+
display: 'inline-flex',
606+
alignItems: 'center',
607+
justifyContent: 'center',
608+
gap: 8,
609+
}}
610+
>
611+
<FontAwesomeIcon icon={faDiscord} />
612+
Login with Discord
613+
</a>
614+
)}
574615
</div>
575616
)}
576617

0 commit comments

Comments
 (0)