| | |
| | | |
| | | @Autowired |
| | | CustomerService customerService; |
| | | |
| | | |
| | | @Autowired |
| | | OtpUtilService otpUtilService; |
| | | |
| | | |
| | | @Autowired |
| | | CustomerRepository customerRepository; |
| | | |
| | |
| | | |
| | | @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(); |
| | | } |
| | | |
| | | |
| | | String jwt = customerAuthService.authorize(customer, verifyOtpParam.getIndexKey(), verifyOtpParam.getOtpCode()); |
| | | HttpHeaders httpHeaders = new HttpHeaders(); |
| | | httpHeaders.add(JWTFilter.AUTHORIZATION_HEADER, "Bearer" + jwt); |
| | |
| | | httpHeaders.add(JWTFilter.AUTHORIZATION_HEADER, "Bearer" + jwt); |
| | | return new ResponseEntity<>(new UserJWTController.JWTToken(jwt), httpHeaders, HttpStatus.OK); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |