archetecture security fix
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.findEmployeeWithCompanyById = findEmployeeWithCompanyById;
|
||||
exports.findEmployeeById = findEmployeeById;
|
||||
exports.findEmployeeWithCompanyByEmail = findEmployeeWithCompanyByEmail;
|
||||
exports.findActiveEmployeeByEmail = findActiveEmployeeByEmail;
|
||||
exports.setPasswordResetToken = setPasswordResetToken;
|
||||
exports.updatePreferredLanguage = updatePreferredLanguage;
|
||||
exports.findEmployeeByResetToken = findEmployeeByResetToken;
|
||||
exports.resetPassword = resetPassword;
|
||||
const prisma_1 = require("../../lib/prisma");
|
||||
function findEmployeeWithCompanyById(id) {
|
||||
return prisma_1.prisma.employee.findUnique({
|
||||
where: { id },
|
||||
include: { company: true },
|
||||
});
|
||||
}
|
||||
function findEmployeeById(id) {
|
||||
return prisma_1.prisma.employee.findUnique({
|
||||
where: { id },
|
||||
});
|
||||
}
|
||||
function findEmployeeWithCompanyByEmail(email) {
|
||||
return prisma_1.prisma.employee.findFirst({
|
||||
where: {
|
||||
email: {
|
||||
equals: email,
|
||||
mode: 'insensitive',
|
||||
},
|
||||
},
|
||||
include: { company: true },
|
||||
});
|
||||
}
|
||||
function findActiveEmployeeByEmail(email) {
|
||||
return prisma_1.prisma.employee.findFirst({
|
||||
where: {
|
||||
email: {
|
||||
equals: email,
|
||||
mode: 'insensitive',
|
||||
},
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
function setPasswordResetToken(id, passwordResetToken, passwordResetExpiresAt) {
|
||||
return prisma_1.prisma.employee.update({
|
||||
where: { id },
|
||||
data: { passwordResetToken, passwordResetExpiresAt },
|
||||
});
|
||||
}
|
||||
function updatePreferredLanguage(id, preferredLanguage) {
|
||||
return prisma_1.prisma.employee.update({
|
||||
where: { id },
|
||||
data: { preferredLanguage },
|
||||
});
|
||||
}
|
||||
function findEmployeeByResetToken(token) {
|
||||
return prisma_1.prisma.employee.findFirst({
|
||||
where: {
|
||||
passwordResetToken: token,
|
||||
passwordResetExpiresAt: { gt: new Date() },
|
||||
},
|
||||
});
|
||||
}
|
||||
function resetPassword(id, passwordHash) {
|
||||
return prisma_1.prisma.employee.update({
|
||||
where: { id },
|
||||
data: {
|
||||
passwordHash,
|
||||
passwordResetToken: null,
|
||||
passwordResetExpiresAt: null,
|
||||
},
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=auth.employee.repo.js.map
|
||||
Reference in New Issue
Block a user