AuthController.java 文件源码

java
阅读 22 收藏 0 点赞 0 评论 0

项目:iotplatform 作者:
@PreAuthorize("isAuthenticated()")
@RequestMapping(value = "/auth/changePassword", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
public void changePassword (
        @RequestParam(value = "currentPassword") String currentPassword,
        @RequestParam(value = "newPassword") String newPassword) throws IoTPException {
    try {
        SecurityUser securityUser = getCurrentUser();
        UserCredentials userCredentials = userService.findUserCredentialsByUserId(securityUser.getId());
        if (!passwordEncoder.matches(currentPassword, userCredentials.getPassword())) {
            throw new IoTPException("Current password doesn't match!", IoTPErrorCode.BAD_REQUEST_PARAMS);
        }
        userCredentials.setPassword(passwordEncoder.encode(newPassword));
        userService.saveUserCredentials(userCredentials);
    } catch (Exception e) {
        throw handleException(e);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号