From eb2d7d3d9fc64ac74a5f6575057d1566e6657b96 Mon Sep 17 00:00:00 2001
From: Jack <jack.su@pollex.com.tw>
Date: 星期三, 29 十二月 2021 19:37:01 +0800
Subject: [PATCH] [ADD] 新增預約單備註API [ADD] 更新預約單備註API [ADD] 刪除預約單備註API [ADD] 顧問查詢自己的預約單清單時帶出備註資料

---
 pamapi/src/main/java/com/pollex/pam/security/provider/OtpAuthenticationProvider.java |   29 ++++++++---------------------
 1 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/pamapi/src/main/java/com/pollex/pam/security/provider/OtpAuthenticationProvider.java b/pamapi/src/main/java/com/pollex/pam/security/provider/OtpAuthenticationProvider.java
index 100a2f8..3802087 100644
--- a/pamapi/src/main/java/com/pollex/pam/security/provider/OtpAuthenticationProvider.java
+++ b/pamapi/src/main/java/com/pollex/pam/security/provider/OtpAuthenticationProvider.java
@@ -1,16 +1,14 @@
 package com.pollex.pam.security.provider;
 
+import com.pollex.pam.web.rest.errors.CustomerNotRegisteredException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.AuthenticationException;
 import org.springframework.stereotype.Component;
 
 import com.pollex.pam.domain.Customer;
-import com.pollex.pam.domain.OtpTmp;
-import com.pollex.pam.enums.OtpTmpStatusEnum;
 import com.pollex.pam.repository.CustomerRepository;
 import com.pollex.pam.security.token.OtpAuthenticationToken;
 import com.pollex.pam.service.CustomerAuthService;
@@ -25,13 +23,13 @@
 
     @Autowired
     CustomerAuthService customerAuthService;
-    
+
     @Autowired
     CustomerRepository customerRepository;
-    
+
     @Autowired
     OtpTmpService otpTmpService;
-    
+
     @Autowired
     OtpUtilService otpUtilService;
 
@@ -41,26 +39,15 @@
         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("");
+    		throw new CustomerNotRegisteredException();
     	}
-    	
+
     	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);
-	}
-
-		
 }

--
Gitblit v1.8.0