Skip to content

Commit

Permalink
fix: 修复个人中心密码设置状态显示错误的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Oct 16, 2023
1 parent 8d39493 commit b04a228
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public class UpdatePasswordRequest implements Serializable {
*/
@Schema(description = "当前密码(加密后)",
example = "E7c72TH+LDxKTwavjM99W1MdI9Lljh79aPKiv3XB9MXcplhm7qJ1BJCj28yaflbdVbfc366klMtjLIWQGqb0qw==")
@NotBlank(message = "当前密码不能为空")
private String oldPassword;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ public void updateBasicInfo(UpdateBasicInfoRequest request, Long id) {
public void updatePassword(String oldPassword, String newPassword, Long id) {
CheckUtils.throwIfEqual(newPassword, oldPassword, "新密码不能与当前密码相同");
UserDO user = super.getById(id);
CheckUtils.throwIfNotEqual(SecureUtils.md5Salt(oldPassword, id.toString()), user.getPassword(), "当前密码错误");
String password = user.getPassword();
if (StrUtil.isNotBlank(password)) {
CheckUtils.throwIfNotEqual(SecureUtils.md5Salt(oldPassword, id.toString()), password, "当前密码错误");
}
// 更新密码和密码重置时间
LocalDateTime now = LocalDateTime.now();
baseMapper.lambdaUpdate().set(UserDO::getPassword, SecureUtils.md5Salt(newPassword, id.toString()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
>
<a-form ref="formRef" :model="form" :rules="rules" size="large">
<a-form-item
v-if="userStore.pwdResetTime"
:label="
$t('userCenter.securitySettings.updatePwd.form.label.oldPassword')
"
Expand Down Expand Up @@ -197,6 +198,7 @@
oldPassword: encryptByRsa(form.oldPassword) || '',
newPassword: encryptByRsa(form.newPassword) || '',
}).then((res) => {
userStore.getInfo();
handleCancel();
proxy.$message.success(res.msg);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ public R updateBasicInfo(@Validated @RequestBody UpdateBasicInfoRequest updateBa
public R updatePassword(@Validated @RequestBody UpdatePasswordRequest updatePasswordRequest) {
String rawOldPassword =
ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(updatePasswordRequest.getOldPassword()));
ValidationUtils.throwIfBlank(rawOldPassword, "当前密码解密失败");
ValidationUtils.throwIfNull(rawOldPassword, "当前密码解密失败");
String rawNewPassword =
ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(updatePasswordRequest.getNewPassword()));
ValidationUtils.throwIfBlank(rawNewPassword, "新密码解密失败");
ValidationUtils.throwIfNull(rawNewPassword, "新密码解密失败");
ValidationUtils.throwIf(!ReUtil.isMatch(RegexConsts.PASSWORD, rawNewPassword),
"密码长度为 6 到 32 位,可以包含字母、数字、下划线,特殊字符,同时包含字母和数字");
userService.updatePassword(rawOldPassword, rawNewPassword, LoginHelper.getUserId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ VALUES
INSERT IGNORE INTO `sys_user`
(`id`, `username`, `nickname`, `password`, `gender`, `email`, `phone`, `avatar`, `description`, `status`, `is_system`, `pwd_reset_time`, `dept_id`, `create_user`, `create_time`, `update_user`, `update_time`)
VALUES
(1, 'admin', '超级管理员', '9802815bcc5baae7feb1ae0d0566baf2', 1, '[email protected]', '18888888888', NULL, '系统初始用户', 1, b'1', NULL, 1, 1, NOW(), NULL, NULL),
(2, 'test', '测试员', '8e114197e1b33783a00542ad67e80516', 2, NULL, NULL, NULL, NULL, 2, b'0', NULL, 5, 1, NOW(), NULL, NULL);
(1, 'admin', '超级管理员', '9802815bcc5baae7feb1ae0d0566baf2', 1, '[email protected]', '18888888888', NULL, '系统初始用户', 1, b'1', NOW(), 1, 1, NOW(), NULL, NULL),
(2, 'test', '测试员', '8e114197e1b33783a00542ad67e80516', 2, NULL, NULL, NULL, NULL, 2, b'0', NOW(), 5, 1, NOW(), NULL, NULL);

-- 初始化默认角色和菜单关联数据
INSERT IGNORE INTO `sys_role_menu`
Expand Down

0 comments on commit b04a228

Please sign in to comment.