| | |
| | | import com.xinquan.auth.form.AppLoginBody; |
| | | import com.xinquan.auth.form.AppRegisterBody; |
| | | import com.xinquan.auth.form.VerifyResultVO; |
| | | import com.xinquan.auth.util.HWSendSms; |
| | | import com.xinquan.auth.util.HuaWeiSMSUtil; |
| | | import com.xinquan.common.core.constant.CacheConstants; |
| | | import com.xinquan.common.core.constant.Constants; |
| | |
| | | |
| | | LoginUser userInfo = userResult.getData(); |
| | | SysUser user = userResult.getData().getSysUser(); |
| | | if (user.getStatus().equals("1")){ |
| | | throw new ServiceException("对不起,您的账号:" + username + " 已被冻结,请联系管理员"); |
| | | } |
| | | if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) |
| | | { |
| | | recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除"); |
| | |
| | | throw new ServiceException("验证码错误"); |
| | | } |
| | | //调用远程服务查询用户信息 |
| | | AppUser appUser = remoteAppUserService.getUserByCondition( |
| | | AppUser appUser = remoteAppUserService.getUserByCondition1( |
| | | AppUserDTO.builder().cellPhone(cellPhone).build(), |
| | | SecurityConstants.INNER).getData(); |
| | | if (Objects.nonNull(appUser)) |
| | |
| | | appLoginUser.setCellPhone(cellPhone); |
| | | appLoginUser.setAppUserId(appUserInfo.getId()); |
| | | appLoginUser.setSysUser(sysUser); |
| | | |
| | | return appLoginUser; |
| | | } |
| | | |
| | |
| | | |
| | | if (StringUtils.isNotBlank(cellPhone) && StringUtils.isNotBlank(captcha)) { |
| | | String key = keyPrefix + cellPhone; |
| | | String key1 = CacheConstants.APP_PASSWORD_CAPTCHA_CODE_PREFIX + cellPhone; |
| | | String code = redisService.getCacheObject(key); |
| | | String code1 = redisService.getCacheObject(key1); |
| | | // 万能验证码 |
| | | if (captcha.equals("123456") || (StringUtils.isNotBlank(code) && code.equals( |
| | | if (captcha.equals("220125") || (StringUtils.isNotBlank(code) && code.equals( |
| | | captcha))||(StringUtils.isNotBlank(code1) && code1.equals( |
| | | captcha))) { |
| | | redisService.deleteObject(key); |
| | | return true; |
| | |
| | | return CacheConstants.APP_VERIFY_CAPTCHA_CODE_PREFIX; |
| | | case 5: |
| | | return CacheConstants.APP_CHANGE_PHONE_CODE_PREFIX; |
| | | case 6: |
| | | return CacheConstants.ADD_CARD_PHONE_CODE_PREFIX; |
| | | case 7: |
| | | return CacheConstants.MANAGEMENT_PASSWORD_SECRET_PREFIX; |
| | | default: |
| | | return ""; |
| | | } |
| | | |
| | | } |
| | | @Autowired |
| | | private HWSendSms hwSendSms; |
| | | /** |
| | | * 发送验证码 |
| | | * |
| | |
| | | TimeUnit.MINUTES); |
| | | log.info("发送验证码成功,手机号:{} 验证码:{}", cellPhone, code); |
| | | // TODO 修改sender参数及templateId |
| | | HuaWeiSMSUtil.sendSms("[\"" + code + "\"]", cellPhone, "8823121426646", |
| | | "767ad27dce184a32a4b4863517fbd301\n"); |
| | | HuaWeiSMSUtil.sendSms("[\"" + code + "\"]", cellPhone, "8825010822864", |
| | | "c1df549e89724e3db05b018524728d41"); |
| | | |
| | | // hwSendSms.sendSms(code, cellPhone); |
| | | } catch (Exception e) { |
| | | log.error("发送短信失败", e); |
| | | throw new ServiceException("验证码发送失败"); |
| | |
| | | if (StringUtils.isNull(appUser)) { |
| | | recordLogService.recordLogininfor(body.getCellPhone(), Constants.LOGIN_FAIL, |
| | | "登录用户不存在"); |
| | | throw new ServiceException("登录用户:" + body.getCellPhone() + " 不存在"); |
| | | throw new ServiceException("登录用户:" + body.getCellPhone() + " 不存在",500); |
| | | } |
| | | // 1:正常 2:冻结 3:注销 |
| | | if (appUser.getUserStatus().equals(AppUserStatusEnum.FROZEN.getCode())) { |
| | | recordLogService.recordLogininfor(body.getCellPhone(), Constants.LOGIN_FAIL, |
| | | "账号已冻结"); |
| | | throw new ServiceException("账号已冻结"); |
| | | throw new ServiceException("账号已冻结",500); |
| | | } |
| | | if (appUser.getUserStatus().equals(AppUserStatusEnum.LOGOUT.getCode())) { |
| | | recordLogService.recordLogininfor(body.getCellPhone(), Constants.LOGIN_FAIL, |
| | | "账号已注销"); |
| | | throw new ServiceException("账号已注销"); |
| | | throw new ServiceException("账号已注销",500); |
| | | } |
| | | // 查询系统用户信息 |
| | | SysUser sysUser = sysUserClient.getSysUser(appUser.getUserId()).getData(); |
| | | if (StringUtils.isNull(sysUser)) { |
| | | recordLogService.recordLogininfor(body.getCellPhone(), Constants.LOGIN_FAIL, |
| | | "登录用户不存在"); |
| | | throw new ServiceException("登录用户:" + body.getCellPhone() + " 不存在"); |
| | | throw new ServiceException("登录用户:" + body.getCellPhone() + " 不存在",500); |
| | | } |
| | | passwordService.validate(sysUser, body.getPassword()); |
| | | // if (!sysUser.getPassword().equals(body.getPassword())){ |
| | |
| | | * @param appleId 苹果id |
| | | * @return |
| | | */ |
| | | public AppLoginUser appleLogin(String appleId) { |
| | | R<AppLoginUser> userResult = remoteAppUserService.appleLogin(appleId, |
| | | public AppLoginUser appleLogin(String appleId,String device) { |
| | | R<AppLoginUser> userResult = remoteAppUserService.appleLogin(appleId,device, |
| | | SecurityConstants.INNER); |
| | | if (R.FAIL == userResult.getCode()) { |
| | | throw new ServiceException(userResult.getMsg()); |
| | |
| | | throw new ServiceException("用户不存在或已注销"); |
| | | } |
| | | // 修改密码 |
| | | sysUser.setPassword(body.getPassword()); |
| | | sysUser.setPassword(SecurityUtils.encryptPassword(body.getPassword())); |
| | | sysUserClient.updateUser(sysUser); |
| | | redisService.deleteObject(CacheConstants.APP_PASSWORD_SECRET_PREFIX + body.getCellPhone()); |
| | | } |
| | |
| | | } |
| | | |
| | | public AppLoginUser verifyCellPhone(AppVerifyCellPhoneBody body) { |
| | | if (!body.getCaptcha().equals("123456")){ |
| | | if (!body.getCaptcha().equals("220125")){ |
| | | Boolean res = redisService.hasKey( |
| | | CacheConstants.APP_VERIFY_CAPTCHA_CODE_PREFIX + body.getCellPhone()); |
| | | if (!res) { |