|
@@ -104,7 +104,7 @@ public class SysUserController extends BaseController {
|
|
|
@PostMapping("/list")
|
|
|
@PreAuthorize("@ss.hasPermi('system:user:list')")
|
|
|
public AjaxResult list(@RequestBody SysUserVo sysUserVo) {
|
|
|
- sysUserVo= (SysUserVo) dataScoreUtil.setDataScore(getUserId(),sysUserVo);
|
|
|
+ sysUserVo = (SysUserVo) dataScoreUtil.setDataScore(getUserId(), sysUserVo);
|
|
|
LambdaQueryWrapper<SysUser> wrapper = new LambdaQueryWrapper<SysUser>();
|
|
|
if (!ObjectUtils.isEmpty(sysUserVo.getUserName())) {
|
|
|
wrapper.like(SysUser::getUserName, sysUserVo.getUserName());
|
|
@@ -121,15 +121,15 @@ public class SysUserController extends BaseController {
|
|
|
if (!ObjectUtils.isEmpty(sysUserVo.getStatus())) {
|
|
|
wrapper.eq(SysUser::getStatus, sysUserVo.getStatus());
|
|
|
}
|
|
|
- if(!sysUserVo.getDsFlay()){
|
|
|
- if (!ObjectUtils.isEmpty(sysUserVo.getDsUserId())){
|
|
|
+ if (!sysUserVo.getDsFlay()) {
|
|
|
+ if (!ObjectUtils.isEmpty(sysUserVo.getDsUserId())) {
|
|
|
wrapper.eq(SysUser::getCreateBy, sysUserVo.getDsUserId()).or();
|
|
|
}
|
|
|
- if (!ObjectUtils.isEmpty(sysUserVo.getDsDeptId())){
|
|
|
- wrapper.eq(SysUser::getDeptId,sysUserVo.getDsDeptId()).or();
|
|
|
+ if (!ObjectUtils.isEmpty(sysUserVo.getDsDeptId())) {
|
|
|
+ wrapper.eq(SysUser::getDeptId, sysUserVo.getDsDeptId()).or();
|
|
|
}
|
|
|
- if (!ObjectUtils.isEmpty(sysUserVo.getDsDeptIds())){
|
|
|
- wrapper.in(SysUser::getDeptId,sysUserVo.getDsDeptIds());
|
|
|
+ if (!ObjectUtils.isEmpty(sysUserVo.getDsDeptIds())) {
|
|
|
+ wrapper.in(SysUser::getDeptId, sysUserVo.getDsDeptIds());
|
|
|
}
|
|
|
}
|
|
|
IPage<SysUser> page = userService.page(new Page<>(sysUserVo.getPageNum(), sysUserVo.getPageSize()), wrapper);
|
|
@@ -345,14 +345,10 @@ public class SysUserController extends BaseController {
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
|
|
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
- @PutMapping("/resetPwd")
|
|
|
- public AjaxResult resetPwd(@RequestBody SysUser user) {
|
|
|
-// boolean matches = user.getPassword().matches(PW_PATTERN);
|
|
|
-// if (!matches) {
|
|
|
-// return error("您的密码太简单!需要包含大小英文、数字、特殊字符、并且长度8-20");
|
|
|
-// }
|
|
|
-// userService.checkUserAllowed(user);
|
|
|
-// userService.checkUserDataScope(user.getId());
|
|
|
+ @PutMapping("/resetPwd/{id}")
|
|
|
+ public AjaxResult resetPwd(@PathVariable(value = "id") Long id) {
|
|
|
+ SysUser user = new SysUser();
|
|
|
+ user.setId(id);
|
|
|
user.setPassword(SecurityUtils.encryptPassword(defaultPassword));
|
|
|
user.setUpdateBy(getUsername());
|
|
|
return toAjax(userService.resetPwd(user));
|
|
@@ -365,16 +361,28 @@ public class SysUserController extends BaseController {
|
|
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping("/updatePwd")
|
|
|
public AjaxResult updatePwd(@RequestBody SysUser user) {
|
|
|
- boolean matches = user.getPassword().matches(PW_PATTERN);
|
|
|
+ LoginUser loginUser = getLoginUser();
|
|
|
+ if (!SecurityUtils.matchesPassword(user.getPassword(), loginUser.getPassword())) {
|
|
|
+ return error("修改密码失败,旧密码错误");
|
|
|
+ }
|
|
|
+ boolean matches =user.getNewPassword().matches(PW_PATTERN);
|
|
|
if (!matches) {
|
|
|
return error("您的密码太简单!需要包含大小英文、数字、特殊字符、并且长度8-20");
|
|
|
}
|
|
|
-// userService.checkUserAllowed(user);
|
|
|
-// userService.checkUserDataScope(user.getId());
|
|
|
- user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
|
|
+ if (SecurityUtils.matchesPassword(user.getNewPassword(), loginUser.getPassword())) {
|
|
|
+ return error("新密码不能与旧密码相同");
|
|
|
+ }
|
|
|
+ user.setPassword(SecurityUtils.encryptPassword(user.getNewPassword()));
|
|
|
user.setUpdateBy(getUsername());
|
|
|
- return toAjax(userService.resetPwd(user));
|
|
|
+ if (userService.resetPwd(user)>0) {
|
|
|
+ // 更新缓存用户密码
|
|
|
+ loginUser.getUser().setPassword(SecurityUtils.encryptPassword(user.getNewPassword()));
|
|
|
+ tokenService.setLoginUser(loginUser);
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+ return error("修改密码异常,请联系管理员");
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 状态修改
|
|
|
*/
|