Files
calendar/packages/lib/server/repository/verificationToken.ts
T
Joe Au-YeungGitHubAlex van Andelcubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
86b1db57d5 fix: Resending team invites now updates token expiry date (#21774)
* Create `VerificationTokenRepository`

* Update the verification token expiry when resending the invite

* Handle error

* Fix import

* Get past unique constraint

* Update packages/trpc/server/routers/viewer/teams/resendInvitation.handler.ts

Co-authored-by: Alex van Andel <me@alexvanandel.com>

* Update packages/lib/server/repository/verificationToken.ts

Update set expiry time

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

* Type fix

* Update how we're fetching the token

---------

Co-authored-by: Alex van Andel <me@alexvanandel.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2025-06-11 22:21:58 +00:00

34 lines
688 B
TypeScript

import prisma from "@calcom/prisma";
export class VerificationTokenRepository {
static async updateTeamInviteTokenExpirationDate({
email,
teamId,
expiresInDays,
}: {
email: string;
teamId: number;
expiresInDays: number;
}) {
const expires = new Date(Date.now() + expiresInDays * 24 * 60 * 60 * 1000);
const token = await prisma.verificationToken.findFirst({
where: {
identifier: email,
teamId,
},
});
await prisma.verificationToken.update({
where: {
identifier: email,
teamId,
token: token?.token,
},
data: { expires },
});
return { ...token, expires };
}
}