| | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.SysUserUpdateStatusDTO; |
| | | import com.ruoyi.system.dto.UpdatePwdDTO; |
| | | import com.ruoyi.system.query.SysUserQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.SysUserVO; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.authentication.BadCredentialsException; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 修改密码 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:resetPwd')") |
| | | @ApiOperation(value = "修改密码") |
| | | @Log(title = "用户信息-修改密码", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/updatePwd") |
| | | public AjaxResult updatePwd(@RequestBody UpdatePwdDTO dto) |
| | | { |
| | | SysUser user = userService.selectUserByUserName(dto.getAccount()); |
| | | if(Objects.isNull(user)){ |
| | | return AjaxResult.error("未查询到该账号"); |
| | | } |
| | | userService.checkUserAllowed(user); |
| | | // 校验密码跟原密码是否匹配 |
| | | if (!SecurityUtils.matchesPassword(dto.getOldPassword(), user.getPassword())) { |
| | | throw new BadCredentialsException("输入原密码不正确"); |
| | | } |
| | | if (dto.getPassword().equals(dto.getConfirmPassword())) { |
| | | throw new BadCredentialsException("两次输入密码不一致"); |
| | | } |
| | | // userService.checkUserDataScope(user.getUserId()); |
| | | user.setPassword(SecurityUtils.encryptPassword(dto.getPassword())); |
| | | user.setUpdateBy(getUsername()); |
| | | return AjaxResult.success(userService.resetPwd(user)); |
| | | } |
| | | |
| | | /** |
| | | * 状态修改 |
| | | */ |
| | | @ApiOperation(value = "状态修改") |