diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java index c86250ff..fc984ba1 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java @@ -1,9 +1,11 @@ package com.ruoyi.web.controller.system; import java.util.List; +import java.util.Map; import java.util.Set; import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.system.domain.vo.AlertUserPassVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -19,6 +21,8 @@ import com.ruoyi.framework.web.service.SysLoginService; import com.ruoyi.framework.web.service.SysPermissionService; import com.ruoyi.system.service.ISysMenuService; +import javax.validation.Valid; + /** * 登录验证 * diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index 256367ba..9f592515 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -1,8 +1,13 @@ package com.ruoyi.web.controller.system; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; + +import com.ruoyi.common.annotation.Anonymous; +import com.ruoyi.system.domain.vo.AlertUserPassVo; import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; @@ -248,4 +253,26 @@ public class SysUserController extends BaseController { return success(deptService.selectDeptTreeList(dept)); } + + /** + * 发送短信验证码修改密码 + * @param data + * @return + */ + @Anonymous + @PostMapping("/v1/sendPhoneMessage") + public AjaxResult sendPhoneMessage(@RequestBody Map data){ + return userService.sendPhoneMessage(data.get("phoneNumber")); + } + + /** + * 用户修改密码&【不需要token】 + * @param alertUserPassVo + * @return + */ + @Anonymous + @PostMapping(value = "/v1/codeUpdatePwd") + public AjaxResult codeUpdatePwd(@RequestBody @Valid AlertUserPassVo alertUserPassVo){ + return userService.updataUserPassWord(alertUserPassVo); + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 7cdb0882..789451ec 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -570,6 +570,9 @@ public class SysUserServiceImpl implements ISysUserService */ @Override public AjaxResult sendPhoneMessage(String phoneNumber){ + if(StringUtils.isEmpty(phoneNumber)){ + throw new ServiceException("手机号码不能为空!"); + } String key = "YANZHU.sendPhoneMessage."+phoneNumber; String obj = redisCache.getCacheObject(key); if(obj!=null){ @@ -577,7 +580,7 @@ public class SysUserServiceImpl implements ISysUserService } SysUser sysUser = userMapper.selectUserByUserName(phoneNumber); if(sysUser==null){ - return AjaxResult.success(false); + throw new ServiceException("账号"+phoneNumber+"不存在,请重新输入!"); } String yangZhengMa = RandomUtil.randomNumbers(6); String content = "您正在修改密码,本次验证码为:" + yangZhengMa + ",有效期5分钟。请勿转发或泄漏,如果不是您的操作请忽略。"; @@ -609,7 +612,7 @@ public class SysUserServiceImpl implements ISysUserService if(!SecurityUtils.matchesPassword(alertUserPassVo.getOldPass(),sysUser.getPassword())) { throw new ServiceException("旧密码错误,请重新输入!"); } - if(Objects.equals(alertUserPassVo.getPassword(),alertUserPassVo.getConfPass())){ + if(!Objects.equals(alertUserPassVo.getPassword(),alertUserPassVo.getConfPass())){ throw new ServiceException("两次密码不一致,请重新输入!"); } sysUser.setPassword(SecurityUtils.encryptPassword(alertUserPassVo.getPassword())); @@ -623,7 +626,7 @@ public class SysUserServiceImpl implements ISysUserService if(StringUtils.isEmpty(alertUserPassVo.getCode())){ throw new ServiceException("验证码不能为空!"); } - if(Objects.equals(alertUserPassVo.getPassword(),alertUserPassVo.getConfPass())){ + if(!Objects.equals(alertUserPassVo.getPassword(),alertUserPassVo.getConfPass())){ throw new ServiceException("两次密码不一致,请重新输入!"); } String key = "YANZHU.sendPhoneMessage."+alertUserPassVo.getLoginName()+".VERIFY"; diff --git a/ruoyi-ui/src/api/system/user.js b/ruoyi-ui/src/api/system/user.js index f2f76ef9..8a47d00e 100644 --- a/ruoyi-ui/src/api/system/user.js +++ b/ruoyi-ui/src/api/system/user.js @@ -133,3 +133,21 @@ export function deptTreeSelect() { method: 'get' }) } + +// 发送短信验证码 +export function sendPhoneMessage(data) { + return request({ + url: '/system/user/v1/sendPhoneMessage', + method: 'post', + data: data + }) +} + +// 用户修改密码 +export function codeUpdatePwd(data) { + return request({ + url: '/system/user/v1/codeUpdatePwd', + method: 'post', + data: data + }) +} \ No newline at end of file diff --git a/ruoyi-ui/src/views/flow/flowLabourInfo/index.vue b/ruoyi-ui/src/views/flow/flowLabourInfo/index.vue index 13b12ebc..1e319e94 100644 --- a/ruoyi-ui/src/views/flow/flowLabourInfo/index.vue +++ b/ruoyi-ui/src/views/flow/flowLabourInfo/index.vue @@ -173,7 +173,7 @@