protect /setup and use links for button

This commit is contained in:
Milo Schwartz
2024-11-26 20:30:52 -05:00
parent 7c9e57ef12
commit 41e531306d
11 changed files with 48 additions and 63 deletions

View File

@@ -1,4 +1,7 @@
import { verifySession } from "@app/lib/auth/verifySession";
import { Metadata } from "next";
import { redirect } from "next/navigation";
import { cache } from "react";
export const metadata: Metadata = {
title: `Setup - Pangolin`,
@@ -10,5 +13,12 @@ export default async function SetupLayout({
}: {
children: React.ReactNode;
}) {
const getUser = cache(verifySession);
const user = await getUser();
if (!user) {
redirect("/");
}
return <div className="mt-32">{children}</div>;
}

View File

@@ -44,7 +44,7 @@ export default function StepperForm() {
const debouncedCheckOrgIdAvailability = useCallback(
debounce(checkOrgIdAvailability, 300),
[checkOrgIdAvailability]
[checkOrgIdAvailability],
);
useEffect(() => {
@@ -278,7 +278,7 @@ export default function StepperForm() {
function debounce<T extends (...args: any[]) => any>(
func: T,
wait: number
wait: number,
): (...args: Parameters<T>) => void {
let timeout: NodeJS.Timeout | null = null;