fix: user not saving

This commit is contained in:
Aleksi Lassila
2025-02-09 02:39:24 +02:00
parent 97cd860114
commit db58ed99e8
4 changed files with 11 additions and 6 deletions

View File

@@ -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) {

View File

@@ -79,10 +79,14 @@ export class UsersService {
}
async update(
user: User,
userId: string,
callerUser: User,
updateUserDto: UpdateUserDto,
): Promise<User> {
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) {