diff --git a/backend/src/users/users.controller.ts b/backend/src/users/users.controller.ts index fdd56c2..2ac8b49 100644 --- a/backend/src/users/users.controller.ts +++ b/backend/src/users/users.controller.ts @@ -138,10 +138,8 @@ export class UsersController { throw new NotFoundException(); } - const user = await this.usersService.findOne(id); - const updated = await this.usersService - .update(user, callerUser, updateUserDto) + .update(id, callerUser, updateUserDto) .catch((e) => { console.error(e); if (e === UserServiceError.PasswordMismatch) { diff --git a/backend/src/users/users.service.ts b/backend/src/users/users.service.ts index 9226b1b..9c17726 100644 --- a/backend/src/users/users.service.ts +++ b/backend/src/users/users.service.ts @@ -79,10 +79,14 @@ export class UsersService { } async update( - user: User, + userId: string, callerUser: User, updateUserDto: UpdateUserDto, ): Promise { + const user = await this.userRepository.findOne({ where: { id: userId } }); + + if (!user) throw new Error('Update user: User not found'); + if (updateUserDto.name) user.name = updateUserDto.name; if (updateUserDto.oldPassword !== updateUserDto.password) { diff --git a/src/lib/components/IconButton.svelte b/src/lib/components/IconButton.svelte index 46188b5..aaa0e06 100644 --- a/src/lib/components/IconButton.svelte +++ b/src/lib/components/IconButton.svelte @@ -6,7 +6,7 @@