fix: Case where email platform will spend the email signin link (#7023)

This commit is contained in:
Tom Moor
2024-06-11 23:08:25 -04:00
committed by GitHub
parent 7bf5c4e533
commit b769da2626
2 changed files with 10 additions and 1 deletions

View File

@@ -90,7 +90,15 @@ router.get(
"email.callback", "email.callback",
validate(T.EmailCallbackSchema), validate(T.EmailCallbackSchema),
async (ctx: APIContext<T.EmailCallbackReq>) => { async (ctx: APIContext<T.EmailCallbackReq>) => {
const { token, client } = ctx.input.query; const { token, client, follow } = ctx.input.query;
// The link in the email does not include the follow query param, this
// is to help prevent anti-virus, and email clients from pre-fetching the link
// and spending the token before the user clicks on it. Instead we redirect
// to the same URL with the follow query param added from the client side.
if (!follow) {
return ctx.redirectOnClient(ctx.request.href + "&follow=true");
}
let user!: User; let user!: User;

View File

@@ -15,6 +15,7 @@ export const EmailCallbackSchema = BaseSchema.extend({
query: z.object({ query: z.object({
token: z.string(), token: z.string(),
client: z.nativeEnum(Client).default(Client.Web), client: z.nativeEnum(Client).default(Client.Web),
follow: z.string().default(""),
}), }),
}); });