blob: 289dcab8724979897317b97dff0521607ddba325 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
import { Metadata } from "next";
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 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 (
<Layout>
<h1>Dashboard</h1>
</Layout>
);
}, { returnTo: "/dashboard" });
|