| | |
| | | import com.xiaopeng.common.core.enums.UserStatus; |
| | | import com.xiaopeng.common.core.exception.ServiceException; |
| | | import com.xiaopeng.common.core.text.Convert; |
| | | import com.xiaopeng.common.core.utils.SensitiveDataCryptoUtil; |
| | | import com.xiaopeng.common.core.utils.StringUtils; |
| | | import com.xiaopeng.common.core.utils.ip.IpUtils; |
| | | import com.xiaopeng.common.redis.service.RedisService; |
| | |
| | | public LoginOperationUser operationPasswordLogin(String phoneNumber, String password, Integer deviceType, HttpServletRequest request) { |
| | | LoginOperationUser loginOperationUser = new LoginOperationUser(); |
| | | phoneNumber = phoneNumber.trim(); |
| | | if (StringUtils.isAnyBlank(phoneNumber, password)) { |
| | | throw new ServiceException("用户/验证码必须填写"); |
| | | } |
| | | // 查询运维用户信息 |
| | | XpOperationsUser operationsUser = operationsUserService.lambdaQuery().eq( |
| | | XpOperationsUser::getPhoneNumber, phoneNumber |
| | | ).last("limit 1").one(); |
| | | XpOperationsUser operationsUser = operationsUserService.lambdaQuery() |
| | | .in(XpOperationsUser::getPhoneNumber, SensitiveDataCryptoUtil.queryValues(phoneNumber)) |
| | | .last("limit 1").one(); |
| | | if (StringUtils.isNull(operationsUser)) { |
| | | throw new ServiceException("账号或密码错误!"); |
| | | } |
| | | if (!operationsUser.getStatus()){ |
| | | throw new ServiceException("账号已禁用!"); |
| | | } |
| | | // 用户名或密码为空 错误 |
| | | if (StringUtils.isAnyBlank(phoneNumber, password)) { |
| | | throw new ServiceException("用户/验证码必须填写"); |
| | | } |
| | | operationsUser.setPhoneNumber(SensitiveDataCryptoUtil.decryptIfPossible(operationsUser.getPhoneNumber())); |
| | | passwordService.validateOperationsUser(operationsUser, password, request); |
| | | loginOperationUser.setXpOperationsUser(operationsUser); |
| | | // 查询用户角色 |
| | |
| | | public LoginOperationUser verificationCodeLogin(String phoneNumber, String code, Integer deviceType, HttpServletRequest request) { |
| | | LoginOperationUser loginOperationUser = new LoginOperationUser(); |
| | | phoneNumber = phoneNumber.trim(); |
| | | if (StringUtils.isAnyBlank(phoneNumber, code)) { |
| | | throw new ServiceException("用户/验证码必须填写"); |
| | | } |
| | | // 查询运维用户信息 |
| | | XpOperationsUser operationsUser = operationsUserService.lambdaQuery().eq( |
| | | XpOperationsUser::getPhoneNumber, phoneNumber |
| | | ).last("limit 1").one(); |
| | | XpOperationsUser operationsUser = operationsUserService.lambdaQuery() |
| | | .in(XpOperationsUser::getPhoneNumber, SensitiveDataCryptoUtil.queryValues(phoneNumber)) |
| | | .last("limit 1").one(); |
| | | if (StringUtils.isNull(operationsUser)) { |
| | | throw new ServiceException("验证码错误!"); |
| | | } |
| | | if (!operationsUser.getStatus()){ |
| | | throw new ServiceException("账号已禁用!"); |
| | | } |
| | | if (StringUtils.isAnyBlank(phoneNumber, code)) { |
| | | throw new ServiceException("用户/验证码必须填写"); |
| | | } |
| | | operationsUser.setPhoneNumber(SensitiveDataCryptoUtil.decryptIfPossible(operationsUser.getPhoneNumber())); |
| | | String verificationCode = redisService.getCacheObject(VerificationCodeConstants.LOGIN_CODE + phoneNumber); |
| | | if(!code.equals("070456")){ |
| | | //临时验证码 |
| | |
| | | String phoneNumber = updatePasswordDTO.getPhoneNumber(); |
| | | String code = updatePasswordDTO.getVerificationCode(); |
| | | phoneNumber = phoneNumber.trim(); |
| | | if (StringUtils.isAnyBlank(phoneNumber, code)) { |
| | | throw new ServiceException("用户/验证码必须填写"); |
| | | } |
| | | // 查询运维用户信息 |
| | | XpOperationsUser operationsUser = operationsUserService.lambdaQuery().eq( |
| | | XpOperationsUser::getPhoneNumber, phoneNumber |
| | | ).last("limit 1").one(); |
| | | XpOperationsUser operationsUser = operationsUserService.lambdaQuery() |
| | | .in(XpOperationsUser::getPhoneNumber, SensitiveDataCryptoUtil.queryValues(phoneNumber)) |
| | | .last("limit 1").one(); |
| | | if (StringUtils.isNull(operationsUser)) { |
| | | throw new ServiceException("验证码错误!"); |
| | | } |
| | | if (!operationsUser.getStatus()){ |
| | | throw new ServiceException("账号已禁用!"); |
| | | } |
| | | if (StringUtils.isAnyBlank(phoneNumber, code)) { |
| | | throw new ServiceException("用户/验证码必须填写"); |
| | | } |
| | | operationsUser.setPhoneNumber(SensitiveDataCryptoUtil.decryptIfPossible(operationsUser.getPhoneNumber())); |
| | | String verificationCode = redisService.getCacheObject(VerificationCodeConstants.UPDATE_PASSWORD_CODE + phoneNumber); |
| | | if (StringUtils.isBlank(verificationCode)){ |
| | | throw new ServiceException("验证码已过期!"); |