Discord sign-in makes a basic account (Discord's verified email, no username or password) for T5DE's other sites; it finishes setting up with a username and password to use the hub. Implicit linking by email is off; members link Discord from their account page. Better Auth 1.7.26.
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import type { Metadata } from "next";
|
|
import { redirect } from "next/navigation";
|
|
import { DiscordButton } from "@/components/discord-button";
|
|
import { ErrorText } from "@/components/forms";
|
|
import { NarrowCard } from "@/components/narrow-card";
|
|
import { Separator } from "@/components/ui/separator";
|
|
import { api, getMe, unwrap } from "@/lib/api";
|
|
import { discordError } from "@/lib/discord";
|
|
import { safeNext } from "@/lib/paths";
|
|
import { SignInForm } from "./signin-form";
|
|
|
|
export const metadata: Metadata = { title: "Sign in" };
|
|
|
|
export default async function SignIn({
|
|
searchParams,
|
|
}: {
|
|
searchParams: Promise<{ next?: string | string[]; error?: string | string[] }>;
|
|
}) {
|
|
const params = await searchParams;
|
|
const next = safeNext(params.next);
|
|
if (await getMe()) redirect(next);
|
|
const { discord } = unwrap(await api.hub.get());
|
|
const error = discordError(params.error);
|
|
return (
|
|
<NarrowCard title="Sign in" description="to your T5DE account.">
|
|
<div className="space-y-6">
|
|
{error && <ErrorText>{error}</ErrorText>}
|
|
{discord && (
|
|
<>
|
|
<DiscordButton mode="sign-in" next={next} />
|
|
<div className="flex items-center gap-3 text-xs text-muted-foreground">
|
|
<Separator className="flex-1" />
|
|
or with your username
|
|
<Separator className="flex-1" />
|
|
</div>
|
|
</>
|
|
)}
|
|
<SignInForm next={next} />
|
|
</div>
|
|
</NarrowCard>
|
|
);
|
|
}
|