Skip to content

Commit 173ba8d

Browse files
committed
fix(web): auth-aware marketing nav — no false 'logged out' on the homepage
The public nav always showed Sign in / Start free, so returning to shoplit.in looked like a logout (prompting a needless re-login) even with a valid session. Add MarketingNav (server) that resolves the current user via the session cookie; signed-in visitors now see a Dashboard link + avatar. Wired into the landing, roadmap, get-extension, and legal pages.
1 parent 856a84b commit 173ba8d

8 files changed

Lines changed: 54 additions & 21 deletions

File tree

web/app/(public)/get-extension/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Metadata } from "next";
22
import Link from "next/link";
3-
import { NavBar } from "@/components/nav-bar";
3+
import { MarketingNav } from "@/components/marketing-nav";
44
import { Footer } from "@/components/footer";
55
import { Download, Puzzle, Monitor, Smartphone } from "lucide-react";
66

@@ -27,7 +27,7 @@ const mobileSteps = [
2727
export default function GetExtensionPage() {
2828
return (
2929
<>
30-
<NavBar variant="marketing" />
30+
<MarketingNav />
3131
<main className="mx-auto max-w-2xl px-4 sm:px-6 py-16">
3232
<div className="text-center mb-10">
3333
<span

web/app/(public)/legal/extension-privacy/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { NavBar } from "@/components/nav-bar";
1+
import { MarketingNav } from "@/components/marketing-nav";
22
import { Footer } from "@/components/footer";
33

44
export const metadata = { title: "Extension Privacy · shoplit" };
55

66
export default function ExtensionPrivacyPage() {
77
return (
88
<>
9-
<NavBar variant="marketing" />
9+
<MarketingNav />
1010
<main className="mx-auto max-w-2xl px-4 sm:px-6 py-16">
1111
<h1 className="font-serif text-4xl mb-2">shoplit browser extension — Privacy</h1>
1212
<p className="text-sm text-muted mb-8">Last updated: 2026-05-24</p>

web/app/(public)/legal/privacy/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { NavBar } from "@/components/nav-bar";
1+
import { MarketingNav } from "@/components/marketing-nav";
22
import { Footer } from "@/components/footer";
33

44
export const metadata = { title: "Privacy · shoplit" };
55

66
export default function PrivacyPage() {
77
return (
88
<>
9-
<NavBar variant="marketing" />
9+
<MarketingNav />
1010
<main className="mx-auto max-w-2xl px-4 sm:px-6 py-16">
1111
<h1 className="font-serif text-4xl mb-2">Privacy</h1>
1212
<p className="text-sm text-muted mb-8">Last updated: 2026-05-23</p>

web/app/(public)/legal/terms/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { NavBar } from "@/components/nav-bar";
1+
import { MarketingNav } from "@/components/marketing-nav";
22
import { Footer } from "@/components/footer";
33

44
export const metadata = { title: "Terms · shoplit" };
55

66
export default function TermsPage() {
77
return (
88
<>
9-
<NavBar variant="marketing" />
9+
<MarketingNav />
1010
<main className="mx-auto max-w-2xl px-4 sm:px-6 py-16">
1111
<h1 className="font-serif text-4xl mb-2">Terms</h1>
1212
<p className="text-sm text-muted mb-8">Last updated: 2026-05-23</p>

web/app/(public)/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Link from "next/link";
22
import { ArrowRight, Sparkles } from "lucide-react";
3-
import { NavBar } from "@/components/nav-bar";
3+
import { MarketingNav } from "@/components/marketing-nav";
44
import { Footer } from "@/components/footer";
55
import { CartCard } from "@/components/cart-card";
66
import { CartCover } from "@/components/cart-cover";
@@ -21,7 +21,7 @@ export default async function LandingPage() {
2121
}
2222
return (
2323
<>
24-
<NavBar variant="marketing" />
24+
<MarketingNav />
2525
<main>
2626
{/* HERO — animated gradient background + cascading phone mockups */}
2727
<section className="relative overflow-hidden">

web/app/(public)/roadmap/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Metadata } from "next";
22
import Link from "next/link";
3-
import { NavBar } from "@/components/nav-bar";
3+
import { MarketingNav } from "@/components/marketing-nav";
44
import { Footer } from "@/components/footer";
55
import { RevealOnScroll } from "@/components/reveal-on-scroll";
66
import {
@@ -59,7 +59,7 @@ const ITEMS: Item[] = [
5959
export default function RoadmapPage() {
6060
return (
6161
<>
62-
<NavBar variant="marketing" />
62+
<MarketingNav />
6363
<main className="mx-auto max-w-6xl px-4 sm:px-6">
6464
{/* HERO */}
6565
<section className="pt-16 pb-10 sm:pt-24 sm:pb-14 text-center max-w-2xl mx-auto">

web/components/marketing-nav.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { cookies } from "next/headers";
2+
import { getCurrentUser } from "@/lib/api-client";
3+
import { NavBar } from "./nav-bar";
4+
5+
// Server wrapper for the marketing NavBar: looks up the current user (via the
6+
// forwarded session cookie) so the public chrome reflects login state — a
7+
// signed-in visitor sees "Dashboard", not "Sign in". Safe on logged-out
8+
// visitors (the lookup just returns null).
9+
export async function MarketingNav() {
10+
let user = null;
11+
try {
12+
user = await getCurrentUser({ cookie: cookies().toString() });
13+
} catch {
14+
user = null;
15+
}
16+
return <NavBar variant="marketing" user={user} />;
17+
}

web/components/nav-bar.tsx

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,31 @@ export function NavBar({ variant = "marketing", user }: NavBarProps) {
4848
<Link href="/feedback" className="text-muted hover:text-ink transition-colors">
4949
Feedback
5050
</Link>
51-
<Link href="/login" className="text-muted hover:text-ink transition-colors">
52-
Sign in
53-
</Link>
54-
<Link
55-
href="/login"
56-
className="rounded-full bg-ink text-cream px-4 py-2 font-medium hover:opacity-90 transition-opacity"
57-
>
58-
Start free
59-
</Link>
51+
{user ? (
52+
// Already signed in — reflect it instead of showing "Sign in"
53+
// (otherwise returning to the homepage looks like a logout).
54+
<Link
55+
href="/dashboard"
56+
className="flex items-center gap-2 rounded-full bg-ink text-cream pl-2 pr-4 py-1.5 font-medium hover:opacity-90 transition-opacity"
57+
>
58+
{user.avatarUrl && (
59+
<Image src={user.avatarUrl} width={24} height={24} alt="" className="rounded-full" unoptimized />
60+
)}
61+
Dashboard
62+
</Link>
63+
) : (
64+
<>
65+
<Link href="/login" className="text-muted hover:text-ink transition-colors">
66+
Sign in
67+
</Link>
68+
<Link
69+
href="/login"
70+
className="rounded-full bg-ink text-cream px-4 py-2 font-medium hover:opacity-90 transition-opacity"
71+
>
72+
Start free
73+
</Link>
74+
</>
75+
)}
6076
</div>
6177
)}
6278
{variant === "app" && user && (

0 commit comments

Comments
 (0)