Remove profile plate management and restrict personal profile updates

This commit is contained in:
SepehrYahyaee
2026-10-07 12:51:44 +03:30
parent 431bdea472
commit 073dd9792f
16 changed files with 76 additions and 210 deletions
+11 -3
View File
@@ -1,4 +1,4 @@
import { Injectable } from "@nestjs/common";
import { BadRequestException, Injectable } from "@nestjs/common";
import { UserDbService } from "src/users/entities/db-service/user.db.service";
import { ProfileUserRs } from "./dto/user/profile.dto";
@@ -8,10 +8,18 @@ export class ProfileService {
async getProfileDetail(username: string) {
const userDetail = await this.userDbService.findOne({ username });
return new ProfileUserRs(userDetail, {});
return new ProfileUserRs(userDetail);
}
async updateProfile(username: string, update) {
return await this.userDbService.findOneAndUpdate({ username }, update);
const allowedFields = ["birthDay", "gender", "city", "state", "address"];
if (Object.keys(update).some((field) => !allowedFields.includes(field))) {
throw new BadRequestException("Only personal profile fields can be updated");
}
const userDetail = await this.userDbService.findOneAndUpdate(
{ username },
{ $set: update },
);
return new ProfileUserRs(userDetail);
}
}