Skip to content

Commit

Permalink
feat: improve user patch (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
annarhughes committed Jan 25, 2024
1 parent 2dfd39e commit 87d4dd3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/user/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
Delete,
Get,
Param,
Patch,
Post,
Put,
Query,
Req,
UseGuards,
Expand Down Expand Up @@ -85,7 +85,7 @@ export class UserController {
}

@ApiBearerAuth()
@Put()
@Patch()
@UseGuards(FirebaseAuthGuard)
async updateUser(@Body() updateUserDto: UpdateUserDto, @Req() req: Request) {
return await this.userService.updateUser(updateUserDto, req['user'] as GetUserDto);
Expand Down
12 changes: 5 additions & 7 deletions src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,12 @@ export class UserService {
throw new HttpException('USER NOT FOUND', HttpStatus.NOT_FOUND);
}

user.name = updateUserDto?.name ?? user.name;
user.contactPermission = updateUserDto?.contactPermission ?? user.contactPermission;
user.serviceEmailsPermission =
updateUserDto?.serviceEmailsPermission ?? user.serviceEmailsPermission;
const updatedUser: UserEntity = {
...user,
...updateUserDto,
};

await this.userRepository.save(user);

return user;
return await this.userRepository.save(updatedUser);
}

public async deleteCypressTestUsers(clean = false): Promise<UserEntity[]> {
Expand Down

0 comments on commit 87d4dd3

Please sign in to comment.