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";
|
2023-04-27 15:33:53 -04:00
|
|
|
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
|
|
|
|
};
|
2023-04-25 19:28:07 -04:00
|
|
|
|
|
|
|
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");
|
2023-04-25 19:28:07 -04:00
|
|
|
|
2023-04-27 15:33:53 -04:00
|
|
|
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} />;
|
2023-04-25 19:28:07 -04:00
|
|
|
}
|