diff options
author | 2024-08-11 13:18:04 -0700 | |
---|---|---|
committer | 2024-08-11 13:18:04 -0700 | |
commit | a9ec4cdbdab6f8026128728c34afa3150663a18b (patch) | |
tree | 093a91e2b05dec5a27dc373b71a038ebde9ee433 /frontend/src/app/new-user | |
parent | 32c8b0b24e868505eb46b3dbe2f3e29d467df2e4 (diff) | |
download | ibd-trader-a9ec4cdbdab6f8026128728c34afa3150663a18b.tar.gz ibd-trader-a9ec4cdbdab6f8026128728c34afa3150663a18b.tar.zst ibd-trader-a9ec4cdbdab6f8026128728c34afa3150663a18b.zip |
Add new-user screen
Diffstat (limited to 'frontend/src/app/new-user')
-rw-r--r-- | frontend/src/app/new-user/page.tsx | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/frontend/src/app/new-user/page.tsx b/frontend/src/app/new-user/page.tsx new file mode 100644 index 0000000..57fcf82 --- /dev/null +++ b/frontend/src/app/new-user/page.tsx @@ -0,0 +1,29 @@ +import { Metadata } from "next"; +import { getSession, withPageAuthRequired } from "@auth0/nextjs-auth0"; +import { redirect, RedirectType } from "next/navigation"; +import { createUserServiceClient } from "@/client/client"; +import NewUserForm from "@/components/NewUserForm/NewUserForm"; + +export const metadata: Metadata = { + title: "New User", +}; + +export default withPageAuthRequired(async function NewUser() { + const session = await getSession(); + if (!session) { + redirect("/api/auth/login", RedirectType.replace); + } + + const client = createUserServiceClient(); + const { user } = await client.getUser({ subject: session.user["sub"] }); + if (!user) { + throw new Error("User not found"); + } + + if (user.ibdUsername) { + // User already has IBD credentials + redirect("/dashboard", RedirectType.replace); + } + + return <NewUserForm />; +}); |