Skip to content

Commit

Permalink
test: add me endpoint as test
Browse files Browse the repository at this point in the history
  • Loading branch information
dominik-stumpf committed Nov 20, 2024
1 parent 311500c commit c35e1f4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/actions/me.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use server";

import { GUILD_AUTH_COOKIE_NAME } from "@/config/constants";
import { env } from "@/lib/env";
import { cookies } from "next/headers";

export async function me() {
const token = (await cookies()).get(GUILD_AUTH_COOKIE_NAME);
const response = await fetch(`${env.NEXT_PUBLIC_API}/auth/me`, {
headers: { "X-Auth-Token": token?.value || "" },
});

return response.json();
}
6 changes: 6 additions & 0 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { me } from "@/actions/me";
import { AuthBoundary } from "./AuthBoundary";
import { SignInButton } from "./SignInButton";
import { SignOutButton } from "./SignOutButton";
import { Button } from "./ui/Button";
import { Card } from "./ui/Card";

export const Header = () => (
<header className="flex h-14 items-center justify-between gap-4 p-2">
{/* TODO: NavMenu component */}
<Card className="h-10 w-24 rounded-xl" />

<form action={me}>
<Button type="submit">me (test auth)</Button>
</form>

<AuthBoundary fallback={<SignInButton />}>
<SignOutButton />
</AuthBoundary>
Expand Down

0 comments on commit c35e1f4

Please sign in to comment.