Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/main/java/org/blueline/api/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,21 @@ public ResponseEntity<Void> deleteUser(Authentication authentication) {
}


@GetMapping("/{id}")
@Operation(
summary = "Get user by ID",
description = "Returns the user's information based on the given ID.",
responses = {
@ApiResponse(responseCode = "200", description = "User found"),
@ApiResponse(responseCode = "404", description = "User not found",
content = @Content(schema = @Schema(implementation = ExceptionDto.class)))
},
security = @SecurityRequirement(name = "bearerAuth")
)
public ResponseEntity<UserDto> getUserById(@PathVariable Long id) {
@GetMapping("/{id}")
@Operation(
summary = "Get user by ID",
description = "Returns the user's information based on the given ID.",
responses = {
@ApiResponse(responseCode = "200", description = "User found"),
@ApiResponse(responseCode = "404", description = "User not found",
content = @Content(schema = @Schema(implementation = ExceptionDto.class)))
},
security = @SecurityRequirement(name = "bearerAuth")
)
public ResponseEntity<UserDto> getUserById(@PathVariable Long id) {
UserDto userDto = userService.getUserById(id);
return ResponseEntity.ok(userDto);
}
}

@GetMapping("/auth/verify")
@Operation(
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/blueline/api/model/dto/UserDto.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.blueline.api.model.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.blueline.api.model.enums.Gender;
import org.blueline.api.model.enums.Status;

Expand Down Expand Up @@ -27,6 +28,7 @@ public class UserDto {
@Schema(description = "User's email", requiredMode = Schema.RequiredMode.REQUIRED)
private @Email String email;

@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
@Schema(description = "User's password", requiredMode = Schema.RequiredMode.REQUIRED, accessMode = Schema.AccessMode.WRITE_ONLY)
private String password;

Expand Down
8 changes: 1 addition & 7 deletions src/main/java/org/blueline/api/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,7 @@ public static String generateUniqueFriendCode(long number) {
public UserDto getUserById(Long userId) {
User user = userRepository.findById(userId)
.orElseThrow(() -> new EntityNotFoundException("User not found with id " + userId));

UserDto userDto = modelMapper.map(user, UserDto.class);

// Force le password à null pour ne pas l'exposer dans la réponse
userDto.setPassword(null);

return userDto;
return modelMapper.map(user, UserDto.class);
}


Expand Down
Binary file modified target/classes/org/blueline/api/controller/UserController.class
Binary file not shown.
Binary file not shown.
Binary file modified target/classes/org/blueline/api/model/dto/UserDto.class
Binary file not shown.
Binary file not shown.
Binary file modified target/classes/org/blueline/api/service/UserService.class
Binary file not shown.