* 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>
34 lines
688 B
TypeScript
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 };
|
|
}
|
|
}
|