mirror of
https://github.com/documenso/documenso.git
synced 2026-07-11 05:25:08 +10:00
25 lines
515 B
TypeScript
25 lines
515 B
TypeScript
import { prisma } from '@documenso/prisma';
|
|
|
|
import { AppError, AppErrorCode } from '../../errors/app-error';
|
|
|
|
export interface GetUserByResetTokenOptions {
|
|
token: string;
|
|
}
|
|
|
|
export const getUserByResetToken = async ({ token }: GetUserByResetTokenOptions) => {
|
|
const result = await prisma.passwordResetToken.findFirst({
|
|
where: {
|
|
token,
|
|
},
|
|
include: {
|
|
user: true,
|
|
},
|
|
});
|
|
|
|
if (!result || !result.user) {
|
|
throw new AppError(AppErrorCode.NOT_FOUND);
|
|
}
|
|
|
|
return result.user;
|
|
};
|