Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/users/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import {
import { DeactivateAccountDto, ReactivateAccountDto } from './dto/deactivation.dto';
import { UpdateProfileDto } from './dto/update-profile.dto';

const UNAUTHORIZED_ACTION_MESSAGE = 'You are not authorized to perform this action';

@Controller('users')
export class UsersController {
constructor(private readonly usersService: UsersService) {}
Expand Down Expand Up @@ -125,7 +127,7 @@ export class UsersController {
@Post(':id/export')
async exportData(@Param('id') id: string, @CurrentUser() user: AuthUserPayload) {
if (user.sub !== id && user.role !== UserRole.ADMIN) {
throw new ForbiddenException("You are not authorized to export this user's data");
throw new ForbiddenException(UNAUTHORIZED_ACTION_MESSAGE);
}

try {
Expand Down Expand Up @@ -168,7 +170,7 @@ export class UsersController {
const ownerId = this.extractExportOwnerId(filename);

if (user.sub !== ownerId && user.role !== UserRole.ADMIN) {
throw new ForbiddenException('You are not authorized to download this export');
throw new ForbiddenException(UNAUTHORIZED_ACTION_MESSAGE);
}

res.download(filepath, (err) => {
Expand Down