mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-19 01:48:47 +08:00
忘记密码修改
This commit is contained in:
parent
cf27855ffb
commit
5c0563c1a0
@ -1,6 +1,7 @@
|
|||||||
package org.dromara.web.controller.app;
|
package org.dromara.web.controller.app;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
import cn.dev33.satoken.secure.BCrypt;
|
import cn.dev33.satoken.secure.BCrypt;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
@ -213,6 +214,34 @@ public class EqUserController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 忘记密码
|
||||||
|
*
|
||||||
|
* @param bo 忘记密码
|
||||||
|
*/
|
||||||
|
@RepeatSubmit
|
||||||
|
@SaIgnore
|
||||||
|
@PutMapping("/updatePwdWithEmailCode")
|
||||||
|
public R<Void> updatePwdWithEmailCode(@Validated @RequestBody EqSysUserPasswordBo bo) {
|
||||||
|
// 校验用户类型是否存在
|
||||||
|
if (!validEmail(bo.getUsername())) throw new UserException("user.email.not.valid");
|
||||||
|
validateEmailCode(bo.getTenantId(), bo.getUsername(), bo.getCode());
|
||||||
|
SysUserVo user = userService.selectUserByUserName(bo.getUsername());
|
||||||
|
String password = user.getPassword();
|
||||||
|
//bo.getOldPassword()不为空
|
||||||
|
if (StringUtils.isNotEmpty(bo.getOldPassword())&&!BCrypt.checkpw(bo.getOldPassword(), password)) {
|
||||||
|
return R.fail("修改密码失败,旧密码错误");
|
||||||
|
}
|
||||||
|
if (BCrypt.checkpw(bo.getNewPassword(), password)) {
|
||||||
|
return R.fail("新密码不能与旧密码相同");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userService.resetUserPwd(user.getUserId(), BCrypt.hashpw(bo.getNewPassword())) > 0) {
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
return R.fail("修改密码异常,请联系管理员");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private final ISysDictTypeService dictTypeService;
|
private final ISysDictTypeService dictTypeService;
|
||||||
|
|||||||
@ -75,10 +75,10 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
|
|||||||
long countUserById(Long userId);
|
long countUserById(Long userId);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DataPermission({
|
// @DataPermission({
|
||||||
@DataColumn(key = "deptName", value = "dept_id"),
|
// @DataColumn(key = "deptName", value = "dept_id"),
|
||||||
@DataColumn(key = "userName", value = "user_id")
|
// @DataColumn(key = "userName", value = "user_id")
|
||||||
})
|
// })
|
||||||
int update(@Param(Constants.ENTITY) SysUser user, @Param(Constants.WRAPPER) Wrapper<SysUser> updateWrapper);
|
int update(@Param(Constants.ENTITY) SysUser user, @Param(Constants.WRAPPER) Wrapper<SysUser> updateWrapper);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user