fix(security): resolve all critical, high, and medium security vulnerabilities
This commit is contained in:
1 parent
da26dd1c8d
commit
dc88677169
33 files changed
+438
-85
No files matched your search
@@ -61,6 +61,16 @@ export class CouponInput {
|
||||
targets?: CouponTargetInput[];
|
||||
}
|
||||
|
||||
const ALLOWED_USER_ROLES = [
|
||||
'User_PetOwner',
|
||||
'User_Vet',
|
||||
'User_Clinic',
|
||||
'User_PetShop',
|
||||
'Customer',
|
||||
'Admin',
|
||||
'SUPER_ADMIN',
|
||||
];
|
||||
|
||||
@Injectable()
|
||||
export class AdminService {
|
||||
constructor(
|
||||
@@ -244,6 +254,10 @@ export class AdminService {
|
||||
? await bcrypt.hash(passwordToHash, 10)
|
||||
: '';
|
||||
|
||||
if (dto.role && !ALLOWED_USER_ROLES.includes(dto.role)) {
|
||||
throw new BadRequestException('نقش کاربری مشخص شده نامعتبر است');
|
||||
}
|
||||
|
||||
return this.prisma.user.create({
|
||||
data: {
|
||||
firstName: dto.firstName.trim(),
|
||||
@@ -307,7 +321,12 @@ export class AdminService {
|
||||
if (normalizedMobile !== undefined) updateData.mobile = normalizedMobile;
|
||||
if (normalizedEmail !== undefined)
|
||||
updateData.email = normalizedEmail || null;
|
||||
if (dto.role !== undefined) updateData.role = dto.role;
|
||||
if (dto.role !== undefined) {
|
||||
if (!ALLOWED_USER_ROLES.includes(dto.role)) {
|
||||
throw new BadRequestException('نقش کاربری مشخص شده نامعتبر است');
|
||||
}
|
||||
updateData.role = dto.role;
|
||||
}
|
||||
if (dto.walletBalance !== undefined) {
|
||||
updateData.walletBalance = new Prisma.Decimal(dto.walletBalance);
|
||||
}
|
||||
@@ -322,6 +341,9 @@ export class AdminService {
|
||||
}
|
||||
|
||||
async updateUserRole(id: string, role: string) {
|
||||
if (!ALLOWED_USER_ROLES.includes(role)) {
|
||||
throw new BadRequestException('نقش کاربری مشخص شده نامعتبر است');
|
||||
}
|
||||
return this.prisma.user.update({
|
||||
where: { id },
|
||||
data: { role },
|
||||
|
||||
Reference in new issue
Block a user