Some checks failed
Deploy MineGeo to Dokploy / deploy (push) Failing after 11m31s
65 lines
1.9 KiB
TypeScript
65 lines
1.9 KiB
TypeScript
import { getI18n } from "@/lib/i18n";
|
|
import { cookies } from "next/headers";
|
|
import Link from "next/link";
|
|
import { Header, Footer } from "@/components/Shell";
|
|
import { PasswordForm } from "@/components/PasswordForm";
|
|
import { authClient, rawUser } from "@/lib/supabase";
|
|
import { recoveryCookie, verifyRecoveryGrant } from "@/lib/password-recovery";
|
|
export async function generateMetadata() {
|
|
const { t } = await getI18n();
|
|
return { title: t("Reset password") };
|
|
}
|
|
export default async function ResetPassword() {
|
|
const { t } = await getI18n();
|
|
const [account, jar, client] = await Promise.all([
|
|
rawUser(),
|
|
cookies(),
|
|
authClient(),
|
|
]);
|
|
const { data } = account ? await client.auth.getClaims() : { data: null };
|
|
const sessionId = data?.claims.session_id;
|
|
const valid =
|
|
account &&
|
|
typeof sessionId === "string" &&
|
|
verifyRecoveryGrant(
|
|
jar.get(recoveryCookie)?.value,
|
|
account.id,
|
|
sessionId,
|
|
process.env.SUPABASE_SECRET_KEY!,
|
|
);
|
|
return (
|
|
<>
|
|
<Header />
|
|
<main className="section page-content" id="main-content" tabIndex={-1}>
|
|
<section className="auth-card reset-card">
|
|
<span className="eyebrow">{t("ACCOUNT RECOVERY")}</span>
|
|
<h1>{t("A fresh start.")}</h1>
|
|
{valid ? (
|
|
<>
|
|
<p className="muted">
|
|
{t("Choose a new password for your account.")}
|
|
</p>
|
|
<PasswordForm recovery />
|
|
</>
|
|
) : (
|
|
<>
|
|
<p>
|
|
{t(
|
|
"This reset link has expired or has already been used. Request a fresh link to continue.",
|
|
)}
|
|
</p>
|
|
<Link
|
|
className="button primary"
|
|
href={account ? "/settings" : "/log-in"}
|
|
>
|
|
{t("Request a new reset link →")}
|
|
</Link>
|
|
</>
|
|
)}
|
|
</section>
|
|
</main>
|
|
<Footer />
|
|
</>
|
|
);
|
|
}
|