diff --git a/library-api-users-service/src/main/java/dev/earlspilner/users/mapper/UserMapper.java b/library-api-users-service/src/main/java/dev/earlspilner/users/mapper/UserMapper.java index 374d019..2aa6715 100644 --- a/library-api-users-service/src/main/java/dev/earlspilner/users/mapper/UserMapper.java +++ b/library-api-users-service/src/main/java/dev/earlspilner/users/mapper/UserMapper.java @@ -3,6 +3,7 @@ import dev.earlspilner.users.dto.UserDto; import dev.earlspilner.users.model.User; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; /** * @author Alexander Dudkin @@ -11,4 +12,7 @@ public interface UserMapper { User toUserEntity(UserDto userDto); UserDto toUserDto(User user); + + @Mapping(target = "password", ignore = true) + UserDto toRegisterResponse(User user); } diff --git a/library-api-users-service/src/main/java/dev/earlspilner/users/service/UserServiceImpl.java b/library-api-users-service/src/main/java/dev/earlspilner/users/service/UserServiceImpl.java index a427944..740844b 100644 --- a/library-api-users-service/src/main/java/dev/earlspilner/users/service/UserServiceImpl.java +++ b/library-api-users-service/src/main/java/dev/earlspilner/users/service/UserServiceImpl.java @@ -45,7 +45,7 @@ public UserDto saveUser(UserDto dto) { User user = userMapper.toUserEntity(dto); user.setPassword(passwordEncoder.encode(dto.password())); userRepository.save(user); - return userMapper.toUserDto(user); + return userMapper.toRegisterResponse(user); } @Override