added new condition for security

This commit is contained in:
2025-11-13 19:45:28 +05:30
parent 8d1955f357
commit fb044a4535

View File

@@ -5,6 +5,7 @@ import { PrismaService } from '../../../common/database/prisma.service';
import ApiError from '../../../common/utils/helper/ApiError';
import * as bcrypt from 'bcryptjs';
import { generateOtpHelper } from '../../../common/utils/helper/sendOtp';
import { ROLE } from '@/common/utils/constants/common.constant';
const prismaService = new PrismaService();
const minglarService = new MinglarService(prismaService);
@@ -33,7 +34,7 @@ export const handler = safeHandler(async (
select: { emailAddress: true, id: true, userPassword: true, roleXid: true },
});
if(!user){
if(!user || ![ROLE.MINGLAR_ADMIN, ROLE.CO_ADMIN, ROLE.ACCOUNT_MANAGER].includes(user.roleXid)){
throw new ApiError(404, 'You are not allowed to register directly. Please contact minglar admin.');
}