Skip to content
Snippets Groups Projects
Commit cdcc69ff authored by Peder Arentz Nygaard's avatar Peder Arentz Nygaard
Browse files

Merge branch '39-update-user-classes-in-backend-to-fit-profile-view' into 'main'

added mapping for user details in controller and response in service

Closes #39

See merge request !33
parents f9d736d6 6a6c251d
Branches main
No related tags found
1 merge request!33added mapping for user details in controller and response in service
Pipeline #221657 passed with stages
in 59 seconds
......@@ -146,4 +146,9 @@ public class UserController {
public ResponseEntity<List<SubUser>> getSubUsers(@AuthenticationPrincipal User user) {
return userService.getSubUsers(user);
}
@GetMapping("/details")
public ResponseEntity<User> getUserDetails(@AuthenticationPrincipal User user) {
return userService.getUserDetails(user);
}
}
......@@ -391,4 +391,15 @@ public class UserService {
}
return ResponseEntity.status(HttpStatus.OK).body(optionalSubUserList);
}
public ResponseEntity<User> getUserDetails(User user) {
if (user == null) {
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
}
// Remove sensitive information like password before sending it to the client
user.setPassword(null);
return new ResponseEntity<>(user, HttpStatus.OK);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment