1
0
forked from Yara724/api

YARA-1094, YARA-1095, YARA-1096

This commit is contained in:
SepehrYahyaee
2026-07-12 14:07:27 +03:30
parent c955deda5c
commit 72dec7a917
17 changed files with 1589 additions and 2 deletions

View File

@@ -19,10 +19,12 @@ import {
CreateSuperAdminDto,
CreateFieldExpertAdminDto,
CreateRegistrarAdminDto,
CreateFinancialExpertAdminDto,
} from "./dto/super-admin.dto";
import { RoleEnum } from "src/Types&Enums/role.enum";
import { FieldExpertDbService } from "src/users/entities/db-service/field-expert.db.service";
import { RegistrarDbService } from "src/users/entities/db-service/registrar.db.service";
import { FinancialExpertDbService } from "src/users/entities/db-service/financial-expert.db.service";
@Injectable()
export class SuperAdminService {
@@ -33,6 +35,7 @@ export class SuperAdminService {
private readonly actorAuthService: ActorAuthService,
private readonly fieldExpertDbService: FieldExpertDbService,
private readonly registrarDbService: RegistrarDbService,
private readonly financialExpertDbService: FinancialExpertDbService,
) {}
/** List all super-admin accounts (sans password). */
@@ -99,4 +102,29 @@ export class SuperAdminService {
async createRegistrar(body: CreateRegistrarAdminDto) {
return this.actorAuthService.createRegistrarMock(body);
}
async createFinancialExpert(body: CreateFinancialExpertAdminDto) {
const email = body.email.toLowerCase().trim();
const existing = await this.financialExpertDbService.findOne({ email });
if (existing) {
throw new ConflictException(
"A FinancialExpert with this email already exists.",
);
}
const hashedPassword = await this.hashService.hash(body.password);
const created = await this.financialExpertDbService.create({
email,
password: hashedPassword,
firstName: body.firstName,
lastName: body.lastName,
mobile: body.mobile,
phone: body.phone,
clientKey: new Types.ObjectId(body.clientId),
role: RoleEnum.FINANCIAL_EXPERT,
} as any);
const { password: _pw, ...rest } = (created as any).toObject
? (created as any).toObject()
: (created as any);
return rest;
}
}