| | |
| | | |
| | | @Autowired |
| | | CustomerAuthService customerAuthService; |
| | | |
| | | |
| | | @Autowired |
| | | CustomerRepository customerRepository; |
| | | |
| | | |
| | | @Autowired |
| | | OtpTmpService otpTmpService; |
| | | |
| | | |
| | | @Autowired |
| | | OtpUtilService otpUtilService; |
| | | |
| | |
| | | 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); |
| | | } |
| | | |
| | | |
| | | } |