39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { getI18n } from "@/lib/i18n";
|
|
import { redirect } from "next/navigation";
|
|
import { Header, Footer } from "@/components/Shell";
|
|
import { SignIn } from "@/components/SignIn";
|
|
import { rawUser, accountState } from "@/lib/supabase";
|
|
import { authDestination } from "@/shared/account";
|
|
export async function generateMetadata() {
|
|
const { t } = await getI18n();
|
|
return { title: t("Log in") };
|
|
}
|
|
export default async function LogIn({
|
|
searchParams,
|
|
}: {
|
|
searchParams: Promise<{ next?: string; auth?: string }>;
|
|
}) {
|
|
const query = await searchParams;
|
|
const next = authDestination(query.next);
|
|
const account = await rawUser();
|
|
if (account && (await accountState(account.id)) !== "active")
|
|
redirect("/ban/appeal");
|
|
if (account) redirect(next === "/auth/reset-password" ? "/settings" : next);
|
|
return (
|
|
<>
|
|
<Header />
|
|
<main className="section page-content auth-page">
|
|
<SignIn
|
|
next={next}
|
|
initialError={
|
|
query.auth === "failed"
|
|
? "This sign-in link expired or could not be verified. Request a new link below."
|
|
: ""
|
|
}
|
|
/>
|
|
</main>
|
|
<Footer />
|
|
</>
|
|
);
|
|
}
|