mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 00:32:43 +10:00
chore: refactor code
This commit is contained in:
27
packages/lib/server-only/user/get-last-verification-token.ts
Normal file
27
packages/lib/server-only/user/get-last-verification-token.ts
Normal 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;
|
||||
};
|
||||
Reference in New Issue
Block a user