@ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(method = RequestMethod.PATCH, consumes = MediaType.APPLICATION_JSON_VALUE) public void changePassword(@RequestBody ChangePasswordCommand cmd, User user) { Assert.isTrue(user.getLogin().isPresent(), "Only users with login can update his/her password"); userRepository.updatePassword(user.getLogin().get(), cmd.getPassword()); }
@ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(method = RequestMethod.DELETE) public void delete(User user) { Assert.isTrue(user.getLogin().isPresent(), "Only users with login can delete his/her account"); userRepository.delete(user.getLogin().get()); }
@RequestMapping(method = RequestMethod.GET) public @ResponseBody UserInfo userInfo(User user) { return new UserInfo(user.getUid(), user.getLogin(), user.getAuthorities()); }