Skip to content

Commit

Permalink
redirect and block jankury
Browse files Browse the repository at this point in the history
  • Loading branch information
Redninjale committed Feb 28, 2025
1 parent 90999e9 commit 4806d17
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions my-turborepo/apps/nextjs/src/app/admin/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { auth, signIn } from "@vanni/auth";
import { redirect } from "next/navigation";
import { api } from "~/trpc/server";

export default async function AdminLayout({
children, // will be a page or nested layout
Expand All @@ -12,6 +14,14 @@ export default async function AdminLayout({
await signIn(undefined, { redirectTo: "/admin/jankury" });
}

if (session) {
try {
await api.auth.validateOrganizerAuth();
} catch (e) {
redirect("/");
}
}

console.log("hello");
console.log(session);
return <section>{children}</section>;
Expand Down
4 changes: 2 additions & 2 deletions my-turborepo/apps/nextjs/src/app/organizer/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export default function OrganizerPage() {
<div>
<h1>Welcome to the Organizer Page</h1>
<button onClick={ async () => {
"use server";
await signOut();
("use server");
await signOut({ redirectTo: "/" });
}}>
Sign Out!
</button>
Expand Down

0 comments on commit 4806d17

Please sign in to comment.