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/dashboard | |
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/dashboard')
-rw-r--r-- | frontend/src/app/dashboard/page.tsx | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/frontend/src/app/dashboard/page.tsx b/frontend/src/app/dashboard/page.tsx index 8ca17c6..289dcab 100644 --- a/frontend/src/app/dashboard/page.tsx +++ b/frontend/src/app/dashboard/page.tsx @@ -1,15 +1,34 @@ import { Metadata } from "next"; -import Link from "next/link"; +import { createUserServiceClient } from "@/client/client"; +import { getSession, withPageAuthRequired } from "@auth0/nextjs-auth0"; +import Layout from "@/components/Layout/Layout"; +import { redirect, RedirectType } from "next/navigation"; +import { red } from "next/dist/lib/picocolors"; export const metadata: Metadata = { title: "IBD Trader Dashboard", }; -export default function Dashboard() { +export default withPageAuthRequired(async function Dashboard() { + const client = createUserServiceClient(); + + const user = await getSession(); + if (!user) { + redirect("/api/auth/login", RedirectType.replace); + } + + const dbUser = await client.createUser({ + subject: user.user["sub"], + }); + + // Check if user has IBD credentials + if (!dbUser.user || !dbUser.user.ibdUsername) { + redirect("/new-user", RedirectType.replace); + } + return ( - <div> + <Layout> <h1>Dashboard</h1> - <Link href="/api/auth/logout">Logout</Link> - </div> + </Layout> ); -} +}, { returnTo: "/dashboard" }); |