保誠-保戶業務員媒合平台
HelenHuang
2021-12-24 1d8e72674b2d14270fe5c2ba6fe3be4efa28a924
pamapi/src/main/java/com/pollex/pam/web/rest/OtpResource.java
@@ -3,6 +3,7 @@
import java.util.Arrays;
import java.util.UUID;
import com.pollex.pam.web.rest.errors.CustomerNotRegisteredException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -57,10 +58,10 @@
    @Autowired
    CustomerService customerService;
    @Autowired
    OtpUtilService otpUtilService;
    @Autowired
    CustomerRepository customerRepository;
@@ -83,16 +84,16 @@
    @PostMapping("/verify")
    public ResponseEntity<UserJWTController.JWTToken> verifyOtp(@RequestBody VerifyOtpVM verifyOtpParam) {
       otpUtilService.verifyOtp(verifyOtpParam.getIndexKey(), verifyOtpParam.getOtpCode());
       otpUtilService.verifyOtp(verifyOtpParam);
       Customer customer = customerRepository
                      .findOneByEmailEqualsOrPhoneEquals(verifyOtpParam.getAccount())
                      .orElse(null);
       if (customer == null) {
          return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
          return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
       }
       String jwt = customerAuthService.authorize(customer, verifyOtpParam.getIndexKey(), verifyOtpParam.getOtpCode());
        HttpHeaders httpHeaders = new HttpHeaders();
        httpHeaders.add(JWTFilter.AUTHORIZATION_HEADER, "Bearer" + jwt);
@@ -112,6 +113,6 @@
        httpHeaders.add(JWTFilter.AUTHORIZATION_HEADER, "Bearer" + jwt);
        return new ResponseEntity<>(new UserJWTController.JWTToken(jwt), httpHeaders, HttpStatus.OK);
    }
}