1
0
forked from Yara724/api

Fixed actors profile check and update for all of them

This commit is contained in:
SepehrYahyaee
2026-01-21 16:45:34 +03:30
parent c5fe27934b
commit 1ed46d1609
3 changed files with 9 additions and 4 deletions

View File

@@ -70,7 +70,7 @@ export class ActorAuthService {
res = await this.damageExpertDbService.findOne({ email: username }); res = await this.damageExpertDbService.findOne({ email: username });
break; break;
case RoleEnum.COMPANY: case RoleEnum.COMPANY:
res = await this.insurerExpertDbService.findOne({ username }); res = await this.insurerExpertDbService.findOne({ email: username });
break; break;
default: default:
return null; return null;
@@ -295,7 +295,7 @@ export class ActorAuthService {
async getProfiles(currentUser) { async getProfiles(currentUser) {
const userDetail = await this.dynamicDbController( const userDetail = await this.dynamicDbController(
currentUser.role, currentUser.role,
null, currentUser.role === "company" ? currentUser.username : null,
currentUser.sub, currentUser.sub,
); );
return new ProfileActor(userDetail); return new ProfileActor(userDetail);
@@ -372,7 +372,7 @@ export class ActorAuthService {
} }
// fetch user detail (document or plain object) // 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"); if (!document) throw new NotFoundException("Profile not found");

View File

@@ -12,10 +12,11 @@ export class ProfileActor {
public address: string; public address: string;
public state: string; public state: string;
public city: string; public city: string;
public phone?: string;
constructor(Profile: DamageExpertModel) { constructor(Profile: DamageExpertModel) {
this.email = Profile?.email; this.email = Profile?.email;
this.fullName = Profile?.firstName + " " + Profile?.lastName; this.fullName = `${Profile?.firstName} ${Profile?.lastName}`;
this.nationalCode = Profile?.nationalCode; this.nationalCode = Profile?.nationalCode;
this.insuActivityCo = Profile?.insuActivityCo; this.insuActivityCo = Profile?.insuActivityCo;
this.userType = Profile?.userType; this.userType = Profile?.userType;
@@ -23,6 +24,7 @@ export class ProfileActor {
this.address = Profile?.address; this.address = Profile?.address;
this.state = Profile?.state; this.state = Profile?.state;
this.city = Profile?.city; this.city = Profile?.city;
this.phone = Profile?.phone;
} }
} }

View File

@@ -124,6 +124,9 @@ export class DamageExpertModel {
@Prop({ required: true }) @Prop({ required: true })
mobile: string; mobile: string;
@Prop({ required: false })
phone?: string;
@Prop({ required: false }) @Prop({ required: false })
insuActivityCo?: string | null; insuActivityCo?: string | null;