保誠-保戶業務員媒合平台
wayne
2021-11-29 4b1639583efdb417cdf9a999a74d6d17835cc252
pamapi/src/main/java/com/pollex/pam/security/provider/OtpAuthenticationProvider.java
@@ -25,13 +25,13 @@
    @Autowired
    CustomerAuthService customerAuthService;
    @Autowired
    CustomerRepository customerRepository;
    @Autowired
    OtpTmpService otpTmpService;
    @Autowired
    OtpUtilService otpUtilService;
@@ -41,26 +41,15 @@
        String indexKey = otpAccount.getIndexKey();
        String otpCode = otpAuthenticationToken.getCredentials();
        otpUtilService.verifyOtp(indexKey, otpCode);
       setVerrifiedOtpTmp(account, indexKey);
        otpUtilService.verifyOtp(account, indexKey, otpCode);
       Customer customer = customerRepository.findOneByEmailEqualsOrPhoneEquals(account)
                      .orElse(null);
       if (customer == null) {
          throw new AuthenticationCredentialsNotFoundException("");
       }
       return customerAuthService.buildCustomerAuthToken(customer, otpCode, indexKey);
    }
    private void setVerrifiedOtpTmp(String account, String indexKey) {
       OtpTmp otpTmp = otpTmpService.findByAccountAndIndexKey(account, indexKey);
       otpTmp.setStatus(OtpTmpStatusEnum.VERRIFIED);
       otpTmpService.save(otpTmp);
   }
}