From 1ed46d1609cabd41a0610639f9bef75165aa755e Mon Sep 17 00:00:00 2001 From: SepehrYahyaee <7heycallmegray@gmail.com> Date: Wed, 21 Jan 2026 16:45:34 +0330 Subject: [PATCH] Fixed actors profile check and update for all of them --- src/auth/auth-services/actor.auth.service.ts | 6 +++--- src/auth/dto/actor/profile.actor.dto.ts | 4 +++- src/users/entities/schema/damage-expert.schema.ts | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/auth/auth-services/actor.auth.service.ts b/src/auth/auth-services/actor.auth.service.ts index 402ab3d..2cba56f 100644 --- a/src/auth/auth-services/actor.auth.service.ts +++ b/src/auth/auth-services/actor.auth.service.ts @@ -70,7 +70,7 @@ export class ActorAuthService { res = await this.damageExpertDbService.findOne({ email: username }); break; case RoleEnum.COMPANY: - res = await this.insurerExpertDbService.findOne({ username }); + res = await this.insurerExpertDbService.findOne({ email: username }); break; default: return null; @@ -295,7 +295,7 @@ export class ActorAuthService { async getProfiles(currentUser) { const userDetail = await this.dynamicDbController( currentUser.role, - null, + currentUser.role === "company" ? currentUser.username : null, currentUser.sub, ); return new ProfileActor(userDetail); @@ -372,7 +372,7 @@ export class ActorAuthService { } // fetch user detail (document or plain object) - const document = await this.dynamicDbController(role, null, userId); + const document = await this.dynamicDbController(role, currentUser.role === "company" ? currentUser.username : null, userId); if (!document) throw new NotFoundException("Profile not found"); diff --git a/src/auth/dto/actor/profile.actor.dto.ts b/src/auth/dto/actor/profile.actor.dto.ts index acd7a9a..718f430 100644 --- a/src/auth/dto/actor/profile.actor.dto.ts +++ b/src/auth/dto/actor/profile.actor.dto.ts @@ -12,10 +12,11 @@ export class ProfileActor { public address: string; public state: string; public city: string; + public phone?: string; constructor(Profile: DamageExpertModel) { this.email = Profile?.email; - this.fullName = Profile?.firstName + " " + Profile?.lastName; + this.fullName = `${Profile?.firstName} ${Profile?.lastName}`; this.nationalCode = Profile?.nationalCode; this.insuActivityCo = Profile?.insuActivityCo; this.userType = Profile?.userType; @@ -23,6 +24,7 @@ export class ProfileActor { this.address = Profile?.address; this.state = Profile?.state; this.city = Profile?.city; + this.phone = Profile?.phone; } } diff --git a/src/users/entities/schema/damage-expert.schema.ts b/src/users/entities/schema/damage-expert.schema.ts index d70a392..380f309 100644 --- a/src/users/entities/schema/damage-expert.schema.ts +++ b/src/users/entities/schema/damage-expert.schema.ts @@ -124,6 +124,9 @@ export class DamageExpertModel { @Prop({ required: true }) mobile: string; + @Prop({ required: false }) + phone?: string; + @Prop({ required: false }) insuActivityCo?: string | null;