2023-11-27 12:50:21 +02:00
|
|
|
import { prisma } from '@documenso/prisma';
|
|
|
|
|
|
|
|
|
|
export type GetUserTokensOptions = {
|
|
|
|
|
userId: number;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const getUserTokens = async ({ userId }: GetUserTokensOptions) => {
|
2023-12-31 13:58:15 +11:00
|
|
|
return await prisma.apiToken.findMany({
|
2023-11-27 12:50:21 +02:00
|
|
|
where: {
|
|
|
|
|
userId,
|
2024-10-22 22:53:31 +11:00
|
|
|
teamId: null,
|
2023-11-27 12:50:21 +02:00
|
|
|
},
|
2023-11-28 15:49:46 +02:00
|
|
|
select: {
|
|
|
|
|
id: true,
|
|
|
|
|
name: true,
|
|
|
|
|
algorithm: true,
|
|
|
|
|
createdAt: true,
|
|
|
|
|
expires: true,
|
|
|
|
|
},
|
2023-12-31 13:58:15 +11:00
|
|
|
orderBy: {
|
|
|
|
|
createdAt: 'desc',
|
|
|
|
|
},
|
2023-11-27 12:50:21 +02:00
|
|
|
});
|
|
|
|
|
};
|