Files
webshop/shop/components/auth-button.tsx
DanielS bdbf840529
All checks were successful
Staging Build / build (push) Successful in 2m19s
feat: lock down registration and enforce partner-only logins
2026-06-23 23:59:22 +02:00

27 lines
686 B
TypeScript

import Link from "next/link";
import { Button } from "./ui/button";
import { createClient } from "@/lib/supabase/server";
import { LogoutButton } from "./logout-button";
export async function AuthButton() {
const supabase = await createClient();
// You can also use getUser() which will be slower.
const { data } = await supabase.auth.getClaims();
const user = data?.claims;
return user ? (
<div className="flex items-center gap-4">
Hey, {user.email}!
<LogoutButton />
</div>
) : (
<div className="flex gap-2">
<Button asChild size="sm" variant={"outline"}>
<Link href="/auth/login">Sign in</Link>
</Button>
</div>
);
}