From 2123beca494a9a5b4cfd601248fd15807ce4b79e Mon Sep 17 00:00:00 2001
From: jack <jack.su@pollex.com.tw>
Date: 星期三, 20 七月 2022 14:33:36 +0800
Subject: [PATCH] [BUG] 調整客戶登入發送驗證碼失敗的問題

---
 pamapi/src/main/java/com/pollex/pam/web/rest/OtpResource.java |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/pamapi/src/main/java/com/pollex/pam/web/rest/OtpResource.java b/pamapi/src/main/java/com/pollex/pam/web/rest/OtpResource.java
index 1bc84f9..c6c9b63 100644
--- a/pamapi/src/main/java/com/pollex/pam/web/rest/OtpResource.java
+++ b/pamapi/src/main/java/com/pollex/pam/web/rest/OtpResource.java
@@ -34,6 +34,7 @@
 import com.pollex.pam.service.OtpWebService;
 import com.pollex.pam.business.service.dto.CustomerRegisterDTO;
 import com.pollex.pam.business.service.dto.OtpResponseDTO;
+import com.pollex.pam.business.web.errors.OtpLoginFailException;
 import com.pollex.pam.business.web.vm.OtpLoginVM;
 import com.pollex.pam.business.web.vm.VerifyOtpVM;
 
@@ -72,8 +73,22 @@
     @Autowired
     CustomerRepository customerRepository;
 
-    @PostMapping("/sendOtp")
-    public ResponseEntity<Object> sendOtp(@RequestBody OtpLoginVM login) {
+    @PostMapping("/sendOtp/{imgCode}")
+    public ResponseEntity<Object> sendOtp(@RequestBody OtpLoginVM login
+    		, @PathVariable String imgCode, HttpServletRequest request) {
+    	
+    	HttpSession session = request.getSession();
+    	String sessionImpCode = (String) session.getAttribute("img_code");
+    	
+    	if (!StringUtils.hasText(sessionImpCode)
+				|| !StringUtils.hasText(imgCode)) {
+    		throw new OtpLoginFailException("撽�Ⅳ頛詨�隤�");
+		}
+    	
+    	if(!imgCode.equals(sessionImpCode)) {
+    		throw new OtpLoginFailException("撽�Ⅳ頛詨�隤�");
+    	}
+    	
     	OtpResponseDTO otpResponse;
         if(applicationProperty.isMockLogin()) {
             otpResponse = getMockSendOtpResponse();
@@ -90,20 +105,9 @@
     }
 
     @AuditLoggingInject(type = CUSTOMER_LOGIN)
-    @PostMapping("/verify/{imgCode}")
+    @PostMapping("/verify")
     public ResponseEntity<UserJWTController.JWTToken> verifyOtp(@RequestBody VerifyOtpVM verifyOtpParam
-    		, @PathVariable String imgCode, HttpServletRequest request) {
-    	HttpSession session = request.getSession();
-    	String sessionImpCode = (String) session.getAttribute("img_code");
-    	
-    	if (!StringUtils.hasText(sessionImpCode)
-				|| !StringUtils.hasText(imgCode)) {
-    		return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
-		}
-    	
-    	if(!imgCode.equals(sessionImpCode)) {
-    		return ResponseEntity.status(HttpStatus.BAD_REQUEST).build();
-    	}
+    		) {
     	
     	otpUtilService.verifyOtp(verifyOtpParam);
 

--
Gitblit v1.8.0