Spend login, invite, and email-change links only after a confirm POST so mail scanners cannot use them up.
GET still shows a one-button page, a used invitation can resend or reopen for the signed-in invitee, and an email-change GET no longer signs the account out.
This commit is contained in:
1 parent
600056499c
commit
a725cf1a32
33 files changed
+1002
-89
No files matched your search
@@ -0,0 +1,107 @@
|
||||
"use client";
|
||||
|
||||
import { useId } from "react";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import Login from "../../components/modals/Login";
|
||||
import Button from "../../components/buttons/Button";
|
||||
import ContentLockup from "../../components/type/ContentLockup";
|
||||
|
||||
const confirmPageBgClass =
|
||||
"min-h-[100dvh] bg-[var(--color-surface-invert-brand-primary)]";
|
||||
|
||||
export type ConfirmLinkScreenProps = {
|
||||
title: string;
|
||||
description: string;
|
||||
buttonLabel: string;
|
||||
action: string;
|
||||
token: string;
|
||||
backHref: string;
|
||||
backLabel: string;
|
||||
missingTitle: string;
|
||||
missingDescription: string;
|
||||
missingHref: string;
|
||||
missingButtonLabel: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Figma: Overlay / Modal / Login (22078:587823)
|
||||
* One-button confirm so a mail scanner's GET cannot spend a one-time link.
|
||||
*/
|
||||
export function ConfirmLinkScreen({
|
||||
title,
|
||||
description,
|
||||
buttonLabel,
|
||||
action,
|
||||
token,
|
||||
backHref,
|
||||
backLabel,
|
||||
missingTitle,
|
||||
missingDescription,
|
||||
missingHref,
|
||||
missingButtonLabel,
|
||||
}: ConfirmLinkScreenProps) {
|
||||
const router = useRouter();
|
||||
const titleId = useId();
|
||||
const hasToken = token.length >= 10;
|
||||
const heading = hasToken
|
||||
? { title, description }
|
||||
: { title: missingTitle, description: missingDescription };
|
||||
|
||||
return (
|
||||
<div className={confirmPageBgClass}>
|
||||
<Login
|
||||
isOpen
|
||||
usePortal={false}
|
||||
backdropVariant="solid"
|
||||
onClose={() => {
|
||||
router.push(backHref);
|
||||
}}
|
||||
ariaLabelledBy={titleId}
|
||||
belowCard={
|
||||
<Link
|
||||
href={backHref}
|
||||
className="text-small-paragraph text-[var(--color-content-invert-tertiary,#2d2d2d)] text-center hover:opacity-90"
|
||||
>
|
||||
{backLabel}
|
||||
</Link>
|
||||
}
|
||||
>
|
||||
<div className="flex min-h-0 flex-1 flex-col gap-6 pt-2">
|
||||
<ContentLockup
|
||||
titleId={titleId}
|
||||
title={heading.title}
|
||||
description={heading.description}
|
||||
variant="login"
|
||||
alignment="left"
|
||||
/>
|
||||
{hasToken ? (
|
||||
<form method="POST" action={action} className="mt-auto flex flex-col gap-4">
|
||||
<input type="hidden" name="token" value={token} />
|
||||
<Button
|
||||
type="submit"
|
||||
size="large"
|
||||
buttonType="filled"
|
||||
palette="default"
|
||||
autoFocus
|
||||
className="w-full !justify-center text-center px-[var(--space-400)] py-[var(--space-300)]"
|
||||
>
|
||||
{buttonLabel}
|
||||
</Button>
|
||||
</form>
|
||||
) : (
|
||||
<Button
|
||||
href={missingHref}
|
||||
size="large"
|
||||
buttonType="filled"
|
||||
palette="default"
|
||||
className="mt-auto w-full !justify-center text-center px-[var(--space-400)] py-[var(--space-300)]"
|
||||
>
|
||||
{missingButtonLabel}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</Login>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user