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
@@ -46,6 +46,7 @@ export const POST = apiRoute<RouteContext>(
|
||||
email: true,
|
||||
inviteTokenHash: true,
|
||||
inviteExpiresAt: true,
|
||||
acceptedAt: true,
|
||||
rule: { select: { userId: true, title: true, summary: true, document: true } },
|
||||
},
|
||||
});
|
||||
@@ -56,7 +57,7 @@ export const POST = apiRoute<RouteContext>(
|
||||
if (row.rule.userId !== user.id) {
|
||||
return forbidden();
|
||||
}
|
||||
if (row.inviteTokenHash === null) {
|
||||
if (row.acceptedAt) {
|
||||
return errorJson(
|
||||
"validation_error",
|
||||
"This stakeholder has already accepted the invite",
|
||||
|
||||
@@ -61,7 +61,6 @@ export const GET = apiRoute<RouteContext>(
|
||||
email: true,
|
||||
invitedAt: true,
|
||||
acceptedAt: true,
|
||||
inviteTokenHash: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -72,7 +71,7 @@ export const GET = apiRoute<RouteContext>(
|
||||
invitedAt: r.invitedAt.toISOString(),
|
||||
acceptedAt: r.acceptedAt?.toISOString() ?? null,
|
||||
status:
|
||||
r.inviteTokenHash !== null ? ("pending" as const) : ("accepted" as const),
|
||||
r.acceptedAt != null ? ("accepted" as const) : ("pending" as const),
|
||||
})),
|
||||
});
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user