| | |
| | | } |
| | | 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(); |
| | |
| | | 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()) |
| | |
| | | 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 ""; |
| | | } |
| | |
| | | "登录用户不存在"); |
| | | 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); |
| | |
| | | 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()); |
| | | } |
| | |
| | | } |
| | | |
| | | 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, |