Skip to content

Commit

Permalink
Refactor Header component to remove authentication logic
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunkomath committed Jan 12, 2025
1 parent 7da19a7 commit acf9c25
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions components/layout/header.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { logtoConfig } from "@/app/logto";
import { getLogtoContext, signIn } from "@logto/next/server-actions";
import Image from "next/image";
import Link from "next/link";
import logo from "../../public/images/logo.png";

export async function Header() {
const { isAuthenticated } = await getLogtoContext(logtoConfig);

return (
<header className="absolute inset-x-0 top-0 z-50 text-black dark:text-white">
<nav
Expand All @@ -32,21 +28,9 @@ export async function Header() {
</Link>
</div>

{isAuthenticated ? (
<Link href="/start" prefetch={false}>
Console
</Link>
) : (
<button
type="button"
onClick={async () => {
"use server";
await signIn(logtoConfig);
}}
>
Sign in
</button>
)}
<Link href="/start" prefetch={false}>
Console
</Link>
</nav>
</header>
);
Expand Down

0 comments on commit acf9c25

Please sign in to comment.