Files
yara724-api/src/profile/profile.controller.ts
T
SepehrYahyaee 2056412efe fix: harden profile updates and localize public errors in Persian
Preserve actor and user profile fields during partial updates and validate supported personal data.

Add Persian HTTP error handling, validation translations, regression tests, and audit documentation.
2026-11-04 12:03:04 +03:30

36 lines
1.1 KiB
TypeScript

import { Controller, Get, Body, Patch, UseGuards } from "@nestjs/common";
import { ApiBearerAuth, ApiBody, ApiTags } from "@nestjs/swagger";
import { GlobalGuard } from "src/auth/guards/global.guard";
import { CurrentUser } from "src/decorators/user.decorator";
import { Roles } from "src/decorators/roles.decorator";
import { UpdateUserProfileDtoRq } from "./dto/user/update-profile.dto";
import { ProfileService } from "./profile.service";
@Controller("user/profile")
@ApiTags("user")
@ApiBearerAuth()
@Roles()
export class ProfileController {
constructor(private readonly profileService: ProfileService) {}
@Get()
@UseGuards(GlobalGuard)
async getProfile(@CurrentUser() user) {
return await this.profileService.getProfileDetail(user.username, user.sub);
}
@Patch()
@UseGuards(GlobalGuard)
@ApiBody({ type: UpdateUserProfileDtoRq })
async updateProfile(
@CurrentUser() user,
@Body() body: UpdateUserProfileDtoRq,
) {
return await this.profileService.updateProfile(
user.username,
body as Record<string, unknown>,
user.sub,
);
}
}