Skip to content

Commit

Permalink
fix: add new mapstruct method to map UserDto to send signup response
Browse files Browse the repository at this point in the history
  • Loading branch information
thisdudkin committed Sep 26, 2024
1 parent e2fc1bd commit 5c5a5a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -11,4 +12,7 @@
public interface UserMapper {
User toUserEntity(UserDto userDto);
UserDto toUserDto(User user);

@Mapping(target = "password", ignore = true)
UserDto toRegisterResponse(User user);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5c5a5a0

Please sign in to comment.