| | |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.core.utils.file.MimeTypeUtils; |
| | | import org.dromara.common.core.validate.auth.PasswordGroup; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.satoken.utils.LoginHelper; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.system.domain.bo.SysUserBo; |
| | | import org.dromara.system.domain.bo.SysUserPasswordBo; |
| | | import org.dromara.system.domain.bo.SysUserProfileBo; |
| | | import org.dromara.system.domain.vo.AvatarVo; |
| | | import org.dromara.system.domain.vo.ProfileVo; |
| | |
| | | /** |
| | | * éç½®å¯ç |
| | | * |
| | | * @param newPassword æ§å¯ç |
| | | * @param oldPassword æ°å¯ç |
| | | * @param bo æ°æ§å¯ç |
| | | */ |
| | | @Log(title = "个人信æ¯", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/updatePwd") |
| | | public R<Void> updatePwd(String oldPassword, String newPassword) { |
| | | public R<Void> updatePwd(@Validated(PasswordGroup.class) @RequestBody SysUserPasswordBo bo) { |
| | | SysUserVo user = userService.selectUserById(LoginHelper.getUserId()); |
| | | String password = user.getPassword(); |
| | | if (!BCrypt.checkpw(oldPassword, password)) { |
| | | if (!BCrypt.checkpw(bo.getOldPassword(), password)) { |
| | | return R.fail("ä¿®æ¹å¯ç å¤±è´¥ï¼æ§å¯ç é误"); |
| | | } |
| | | if (BCrypt.checkpw(newPassword, password)) { |
| | | if (BCrypt.checkpw(bo.getNewPassword(), password)) { |
| | | return R.fail("æ°å¯ç ä¸è½ä¸æ§å¯ç ç¸å"); |
| | | } |
| | | |
| | | if (userService.resetUserPwd(user.getUserId(), BCrypt.hashpw(newPassword)) > 0) { |
| | | if (userService.resetUserPwd(user.getUserId(), BCrypt.hashpw(bo.getNewPassword())) > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail("ä¿®æ¹å¯ç å¼å¸¸ï¼è¯·è系管çå"); |