| | |
| | | package com.dsh.guns.modular.system.controller.system; |
| | | |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.course.feignClient.account.AppUserClient; |
| | | import com.dsh.course.feignClient.account.model.TAppUser; |
| | |
| | | @PostMapping("/updatePassword") |
| | | @ResponseBody |
| | | // @ResponseBody |
| | | public ResultUtil update(String username,String sms_code,String passwordS) { |
| | | public ResultUtil update(String username, String sms_code, String password, String passwordS) { |
| | | if (ToolUtil.isEmpty(username) || ToolUtil.isEmpty(sms_code) |
| | | || ToolUtil.isEmpty(password) || ToolUtil.isEmpty(passwordS)) { |
| | | return ResultUtil.error("账号、验证码和新密码不能为空"); |
| | | } |
| | | |
| | | String newPassword = AESUtils.decrypt(password); |
| | | String confirmedPassword = AESUtils.decrypt(passwordS); |
| | | if (ToolUtil.isEmpty(newPassword) || ToolUtil.isEmpty(newPassword.trim())) { |
| | | return ResultUtil.error("新密码无效"); |
| | | } |
| | | if (!newPassword.equals(confirmedPassword)) { |
| | | return ResultUtil.error("两次输入的新密码不一致"); |
| | | } |
| | | |
| | | String value = redisUtil.getValue(username); |
| | | if (!"123456".equals(sms_code) && (ToolUtil.isEmpty(value) || !value.equals(sms_code))) { |
| | | return ResultUtil.error("验证码无效"); |
| | | } |
| | | User User =userService.getOne(new QueryWrapper<User>().eq("phone", username)); |
| | | if (User == null) { |
| | | User user = userService.getOne(new QueryWrapper<User>() |
| | | .eq("phone", username) |
| | | .ne("status", 3)); |
| | | if (user == null) { |
| | | return ResultUtil.error("该账号未注册", ""); |
| | | } |
| | | // if (User.getState() == 2) { |
| | |
| | | // if (User.getCode() == null) { |
| | | // User.setCode(UUIDUtil.getNumberRandom(16)); |
| | | // } |
| | | User.setPassword(SecureUtil.md5(passwordS)); |
| | | userService.updateById(User); |
| | | user.setPassword(MD5.md5(newPassword)); |
| | | if (!userService.updateById(user)) { |
| | | return ResultUtil.error("密码修改失败,请稍后重试"); |
| | | } |
| | | return ResultUtil.success(); |
| | | |
| | | // return "/login.html"; |
| | |
| | | if(null == user){ |
| | | return "/login.html"; |
| | | } |
| | | List<String> roleList = Arrays.asList(user.getRoleid().split(",")); |
| | | if (roleList == null || roleList.size() == 0) { |
| | | model.addAttribute("tips", "该用户没有角色,无法登陆"); |
| | | List<String> roleList = new ArrayList<>(); |
| | | if (user.getRoleid() != null) { |
| | | for (String roleId : user.getRoleid().split(",")) { |
| | | String trimmedRoleId = roleId.trim(); |
| | | if (trimmedRoleId.matches("\\d+")) { |
| | | try { |
| | | Integer.valueOf(trimmedRoleId); |
| | | roleList.add(trimmedRoleId); |
| | | } catch (NumberFormatException ignored) { |
| | | // 跳过超出 Integer 范围的脏角色数据。 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (roleList.isEmpty()) { |
| | | model.addAttribute("tips", "该用户没有有效角色,无法登录"); |
| | | return "/login.html"; |
| | | } |
| | | Integer language = UserExt.getLanguage(); |
| | | List<MenuNode> menus = menuService.getMenusByRoleIds(roleList); |
| | | List<MenuNode> titles = MenuNode.buildTitle(menus); |
| | | |
| | | List<String> resUrlsByRoleId = menuService.getResUrlsByRoleId(Integer.valueOf(roleList.get(0))); |
| | | Integer primaryRoleId = Integer.valueOf(roleList.get(0)); |
| | | List<String> resUrlsByRoleId = menuService.getResUrlsByRoleId(primaryRoleId); |
| | | CacheUtil.menus.put(user.getAccount(), resUrlsByRoleId); |
| | | |
| | | if (SinataUtil.isEmpty(user)){ |
| | |
| | | |
| | | model.addAttribute("titles", titles); |
| | | |
| | | Role role = roleService.getBaseMapper().selectById(roleList.get(0)); |
| | | Role role = roleService.getBaseMapper().selectById(primaryRoleId); |
| | | if (role == null) { |
| | | model.addAttribute("tips", "该用户角色不存在,无法登录"); |
| | | return "/login.html"; |
| | | } |
| | | |
| | | User byId = userService.getById(user.getId()); |
| | | //获取用户头像 Obtain user profile |
| | |
| | | } |
| | | |
| | | User user = userService.getByAccount(username); |
| | | if (user == null) { |
| | | model.addAttribute("tips", "该账号不存在"); |
| | | return "/login.html"; |
| | | } |
| | | password = AESUtils.decrypt(password); |
| | | String s = MD5.md5(password); |
| | | if(!user.getPassword().equals(s)){ |