Skip to content

Commit

Permalink
[SHIBUI-1058]
Browse files Browse the repository at this point in the history
Replaced getPrincipal with getCurrentUser. Now returns the user object
instead of just Principal.getName.
  • Loading branch information
Bill Smith committed Jan 21, 2019
1 parent 4aad65c commit 36ee155
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ public List<User> getAll() {

@Transactional(readOnly = true)
@GetMapping("/current")
public ResponseEntity<?> getPrincipal(Principal principal) {
return ResponseEntity.ok(principal);
public ResponseEntity<?> getCurrentUser(Principal principal) {
if (principal != null && principal.getName() != null) {
return ResponseEntity.ok(userRepository.findByUsername(principal.getName()));
} else {
return ResponseEntity.notFound().build();
}
}

@Transactional(readOnly = true)
Expand Down

0 comments on commit 36ee155

Please sign in to comment.