chore: refactor code

This commit is contained in:
Catalin Pit
2024-02-13 07:50:22 +02:00
parent c432261dd8
commit 149f416be7
4 changed files with 64 additions and 30 deletions

View File

@ -0,0 +1,27 @@
import { prisma } from '@documenso/prisma';
export interface GetLastVerificationTokenOptions {
userId: number;
}
export const getLastVerificationToken = async ({ userId }: GetLastVerificationTokenOptions) => {
const user = await prisma.user.findFirstOrThrow({
where: {
id: userId,
},
include: {
VerificationToken: {
select: {
expires: true,
createdAt: true,
},
orderBy: {
createdAt: 'desc',
},
take: 1,
},
},
});
return user.VerificationToken;
};