| | |
| | | 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; |
| | |
| | | |
| | | @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(); |
| | | 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); |
| | |
| | | httpHeaders.add(JWTFilter.AUTHORIZATION_HEADER, "Bearer" + jwt); |
| | | return new ResponseEntity<>(new UserJWTController.JWTToken(jwt), httpHeaders, HttpStatus.OK); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |