gluestick/src/app/me/page.tsx

37 lines
1.1 KiB
TypeScript
Raw Permalink Normal View History

2023-04-27 13:47:30 -04:00
import { getUser } from "@/auth/auth";
2023-04-26 13:56:59 -04:00
import { getUserInfo } from "@/ldap";
import AboutMe from "./AboutMe";
2023-04-26 21:21:28 -04:00
import { redirect } from "next/navigation";
import { DiscordAuthProvider } from "@/auth/discord";
import { GitHubAuthProvider } from "@/auth/github";
import { AuthProviderState } from "@/auth/AuthProvider";
// this sucks but i'm lazy
const discordFallback: AuthProviderState = {
name: "Discord",
connected: false
};
const githubFallback: AuthProviderState = {
name: "GitHub",
connected: false
};
export default async function Page() {
2023-04-26 13:56:59 -04:00
const user = await getUser();
2023-04-26 21:21:28 -04:00
if (!user) redirect("/login");
2023-04-26 13:56:59 -04:00
const info = await getUserInfo(user);
2023-04-26 22:59:17 -04:00
if (info === null) redirect("/register");
const discord = await user.getDiscord();
const discordState = (await discord?.getState()) ?? discordFallback;
const github = await user.getGitHub();
const githubState = (await github?.getState()) ?? githubFallback;
const providers = [discordState, githubState];
// not sure how to feel about passing it like this
return <AboutMe info={info} providers={providers} />;
}