Ejemplo n.º 1
0
 /** GET /account -> get the current user. */
 @RequestMapping(
     value = "/account",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<UserDTO> getAccount() {
   return Optional.ofNullable(userService.getUserWithAuthorities())
       .map(
           user -> {
             return new ResponseEntity<>(
                 new UserDTO(
                     user.getLogin(),
                     null,
                     user.getFirstName(),
                     user.getLastName(),
                     user.getEmail(),
                     user.getLangKey(),
                     user.getAuthorities()
                         .stream()
                         .map(Authority::getName)
                         .collect(Collectors.toList())),
                 HttpStatus.OK);
           })
       .orElse(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
 }