fix(security): resolve all critical, high, and medium security vulnerabilities
Deploy Canina / deploy (push) Waiting to run
E2E Playwright Tests / Run Full E2E & Security Suites (push) Failing after 11s

This commit is contained in:
parsa committed 2026-09-23 22:05:12 +03:30
1 parent da26dd1c8d
commit dc88677169
33 files changed
+438 -85

No files matched your search

+23 -1
View File
@@ -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 },