修复管理员编辑bug

This commit is contained in:
TinyAnts 2022-11-17 18:07:11 +08:00
parent c64d0151b3
commit ff5b649969
2 changed files with 7 additions and 10 deletions

View File

@ -250,7 +250,7 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
*/
@Override
public void edit(SystemAdminUpdateValidate updateValidate, Integer adminId) {
if (adminId.equals(1) && updateValidate.getId().equals(1)) {
if (!adminId.equals(1) && updateValidate.getId().equals(1)) {
throw new OperateException("您无权限编辑系统管理员!");
}
@ -295,7 +295,7 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
model.setUsername(updateValidate.getUsername());
}
if (StringUtil.isNotNull(updateValidate.getPassword())) {
if (StringUtil.isNotNull(updateValidate.getPassword()) && StringUtil.isNotEmpty(updateValidate.getPassword())) {
String salt = ToolsUtil.randomString(5);
String pwd = ToolsUtil.makeMd5( updateValidate.getPassword().trim() + salt);
model.setPassword(pwd);
@ -305,7 +305,7 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
systemAuthAdminMapper.updateById(model);
this.cacheAdminUserByUid(updateValidate.getId());
if (StringUtil.isNotNull(updateValidate.getPassword())) {
if (StringUtil.isNotNull(updateValidate.getPassword()) && StringUtil.isNotEmpty(updateValidate.getPassword())) {
StpUtil.kickout(updateValidate.getId());
}
}
@ -334,7 +334,7 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
model.setNickname(upInfoValidate.getNickname());
model.setUpdateTime(System.currentTimeMillis() / 1000);
if (StringUtil.isNotNull(upInfoValidate.getPassword())) {
if (StringUtil.isNotNull(upInfoValidate.getPassword()) && StringUtil.isNotEmpty(upInfoValidate.getPassword())) {
String currPassword = ToolsUtil.makeMd5(upInfoValidate.getCurrPassword() + model.getSalt());
Assert.isFalse(!currPassword.equals(model.getPassword()), "当前密码不正确!");
String salt = ToolsUtil.randomString(5);
@ -346,7 +346,7 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
systemAuthAdminMapper.updateById(model);
this.cacheAdminUserByUid(adminId);
if (StringUtil.isNotNull(upInfoValidate.getPassword())) {
if (StringUtil.isNotNull(upInfoValidate.getPassword()) && StringUtil.isNotEmpty(upInfoValidate.getPassword())) {
StpUtil.kickout(adminId);
}
}

View File

@ -18,15 +18,12 @@ public class SystemAdminUpInfoValidate implements Serializable {
@Length(min = 2, max = 30, message = "昵称必须在2~30个字符内")
private String nickname;
@Length(min = 6, max = 32, message = "密码必须在6~32个字符内")
@Length(max = 32, message = "密码必须在6~32个字符内")
private String password="";
@Length(min = 6, max = 32, message = "当前密码错误")
@Length(max = 32, message = "当前密码错误")
private String currPassword="";
@Length(min = 6, max = 32, message = "旧密码错误")
private String oldPassword="";
@Length(max = 200, message = "头像不能超出200个字符")
private String avatar = "";