ff-admin-server/src/service/resetService.ts

28 lines
861 B
TypeScript
Raw Normal View History

2024-11-23 12:11:19 +01:00
import { dataSource } from "../data-source";
import { reset } from "../entity/reset";
2025-01-29 09:42:22 +01:00
import DatabaseActionException from "../exceptions/databaseActionException";
2024-11-23 12:11:19 +01:00
import InternalException from "../exceptions/internalException";
export default abstract class ResetService {
/**
* @description get reset by id
* @param mail string
* @param token string
* @returns {Promise<reset>}
*/
static async getByMailAndToken(mail: string, token: string): Promise<reset> {
return await dataSource
.getRepository(reset)
.createQueryBuilder("reset")
.where("reset.mail = :mail", { mail: mail })
.andWhere("reset.token = :token", { token: token })
.getOneOrFail()
.then((res) => {
return res;
})
.catch((err) => {
2025-01-29 09:42:22 +01:00
throw new DatabaseActionException("SELECT", "reset", err);
2024-11-23 12:11:19 +01:00
});
}
}