无关风月
2024-11-04 64f7ccb9ef8b5a0618e65cddc14b981c1f108ba3
xinquan-auth/src/main/java/com/xinquan/auth/service/SysLoginService.java
@@ -167,10 +167,14 @@
        }
        recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功");
    }
    public static void main(String[] args) {
        String s = SecurityUtils.encryptPassword("E10ADC3949BA59ABBE56E057F20F883E");
        System.out.println(s);
    }
    /**
     * 注册
     */
    @Transactional(rollbackFor = Exception.class)
    public AppLoginUser appRegister(AppRegisterBody appRegisterBody)
    {
        String cellPhone = appRegisterBody.getCellPhone();
@@ -195,7 +199,7 @@
        sysUser.setUserName(cellPhone);
        sysUser.setUserType("01");
        sysUser.setNickName(nickname);
        sysUser.setPassword(SecurityUtils.encryptPassword(password));
        sysUser.setPassword(password);
        R<SysUser> registerResult = remoteUserService.registerAppUserInfo(sysUser, SecurityConstants.INNER);
        if (R.FAIL == registerResult.getCode())
@@ -264,6 +268,8 @@
                return CacheConstants.APP_PASSWORD_CAPTCHA_CODE_PREFIX;
            case 4:
                return CacheConstants.APP_VERIFY_CAPTCHA_CODE_PREFIX;
            case 5:
                return CacheConstants.APP_CHANGE_PHONE_CODE_PREFIX;
            default:
                return "";
        }
@@ -334,10 +340,11 @@
                    "登录用户不存在");
            throw new ServiceException("登录用户:" + body.getCellPhone() + " 不存在");
        }
        // 校验账号密码
        passwordService.validate(sysUser, body.getPassword());
        if (!sysUser.getPassword().equals(body.getPassword())){
            throw new ServiceException("密码错误");
        }
        AppLoginUser appLoginUser = new AppLoginUser();
        appLoginUser.setAppUserId(appUser.getUserId());
        appLoginUser.setAppUserId(appUser.getId());
        appLoginUser.setCellPhone(appUser.getCellPhone());
        appLoginUser.setUsername(sysUser.getNickName());
        appLoginUser.setSysUser(sysUser);
@@ -459,7 +466,7 @@
            throw new ServiceException("用户不存在或已注销");
        }
        // 修改密码
        sysUser.setPassword(SecurityUtils.encryptPassword(body.getPassword()));
        sysUser.setPassword(body.getPassword());
        sysUserClient.updateUser(sysUser);
        redisService.deleteObject(CacheConstants.APP_PASSWORD_SECRET_PREFIX + body.getCellPhone());
    }
@@ -485,15 +492,17 @@
    }
    public AppLoginUser verifyCellPhone(AppVerifyCellPhoneBody body) {
        Boolean res = redisService.hasKey(
                CacheConstants.APP_VERIFY_CAPTCHA_CODE_PREFIX + body.getCellPhone());
        if (!res) {
            throw new ServiceException("验证码已失效,请重新获取");
        }
        // 校验验证码
        if (!verifyCaptcha(body.getCellPhone(), body.getCaptcha(),
                CacheConstants.APP_VERIFY_CAPTCHA_CODE_PREFIX)) {
            throw new ServiceException("验证码不正确");
        if (!body.getCaptcha().equals("123456")){
            Boolean res = redisService.hasKey(
                    CacheConstants.APP_VERIFY_CAPTCHA_CODE_PREFIX + body.getCellPhone());
            if (!res) {
                throw new ServiceException("验证码已失效,请重新获取");
            }
            // 校验验证码
            if (!verifyCaptcha(body.getCellPhone(), body.getCaptcha(),
                    CacheConstants.APP_VERIFY_CAPTCHA_CODE_PREFIX)) {
                throw new ServiceException("验证码不正确");
            }
        }
        // 更新用户系统用户信息
        R<AppLoginUser> result = remoteAppUserService.verifyCellPhone(body,