From 032992c614e6f43117f89e2c72c60e910dd98294 Mon Sep 17 00:00:00 2001 From: Justin Brooks Date: Sat, 12 Oct 2024 01:46:30 -0400 Subject: [PATCH] finish signup credential auth page --- .../[workspaceInviteToken]/page.tsx | 1 - .../src/app/(auth)/sign-up/SignUpCard.tsx | 5 +---- .../app/(auth)/{layout.tsx => sign-up/page.tsx} | 16 ++++++++++++++-- 3 files changed, 15 insertions(+), 7 deletions(-) rename apps/webservice/src/app/(auth)/{layout.tsx => sign-up/page.tsx} (50%) diff --git a/apps/webservice/src/app/(auth)/login/workspace-invite/[workspaceInviteToken]/page.tsx b/apps/webservice/src/app/(auth)/login/workspace-invite/[workspaceInviteToken]/page.tsx index 3e4ba4df..c0c9a6e7 100644 --- a/apps/webservice/src/app/(auth)/login/workspace-invite/[workspaceInviteToken]/page.tsx +++ b/apps/webservice/src/app/(auth)/login/workspace-invite/[workspaceInviteToken]/page.tsx @@ -4,7 +4,6 @@ import { IconPlane } from "@tabler/icons-react"; import { auth, isGoogleAuthEnabled, isOIDCAuthEnabled } from "@ctrlplane/auth"; import { Button } from "@ctrlplane/ui/button"; -import { env } from "~/env"; import { LoginCard } from "../../LoginCard"; export default async function LoginInvitePage() { diff --git a/apps/webservice/src/app/(auth)/sign-up/SignUpCard.tsx b/apps/webservice/src/app/(auth)/sign-up/SignUpCard.tsx index 67969e89..fd541bf8 100644 --- a/apps/webservice/src/app/(auth)/sign-up/SignUpCard.tsx +++ b/apps/webservice/src/app/(auth)/sign-up/SignUpCard.tsx @@ -22,10 +22,7 @@ const schema = z.object({ password: z.string().min(8), }); -export const SignUpCard: React.FC<{ - isGoogleEnabled: boolean; - isOidcEnabled: boolean; -}> = () => { +export const SignUpCard: React.FC = () => { const router = useRouter(); const signUp = api.user.auth.signUp.useMutation(); const form = useForm({ diff --git a/apps/webservice/src/app/(auth)/layout.tsx b/apps/webservice/src/app/(auth)/sign-up/page.tsx similarity index 50% rename from apps/webservice/src/app/(auth)/layout.tsx rename to apps/webservice/src/app/(auth)/sign-up/page.tsx index fa49cbdf..f1082d50 100644 --- a/apps/webservice/src/app/(auth)/layout.tsx +++ b/apps/webservice/src/app/(auth)/sign-up/page.tsx @@ -1,8 +1,20 @@ +import type { Metadata } from "next"; +import { redirect } from "next/navigation"; import { IconPlane } from "@tabler/icons-react"; +import { auth, isCredentialsAuthEnabled } from "@ctrlplane/auth"; import { Button } from "@ctrlplane/ui/button"; -export default function AuthPage({ children }: { children: React.ReactNode }) { +import { SignUpCard } from "./SignUpCard"; + +export const metadata: Metadata = { title: "Ctrlplane Login" }; + +export default async function LoginPage() { + if (!isCredentialsAuthEnabled) redirect("/login"); + + const session = await auth(); + if (session != null) redirect("/"); + return (
@@ -13,7 +25,7 @@ export default function AuthPage({ children }: { children: React.ReactNode }) {
- {children} +
); }