From 4b1639583efdb417cdf9a999a74d6d17835cc252 Mon Sep 17 00:00:00 2001
From: wayne <wayne8692wayne8692@gmail.com>
Date: 星期一, 29 十一月 2021 16:40:04 +0800
Subject: [PATCH] [add] 客戶、顧問登入紀錄

---
 pamapi/src/main/java/com/pollex/pam/service/OtpUtilService.java |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/pamapi/src/main/java/com/pollex/pam/service/OtpUtilService.java b/pamapi/src/main/java/com/pollex/pam/service/OtpUtilService.java
index c9a949f..be48bd2 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/OtpUtilService.java
+++ b/pamapi/src/main/java/com/pollex/pam/service/OtpUtilService.java
@@ -10,7 +10,6 @@
 import org.springframework.stereotype.Service;
 
 import com.pollex.pam.config.ApplicationProperties;
-import com.pollex.pam.security.provider.OtpAuthenticationProvider;
 import com.pollex.pam.service.dto.OtpResponseDTO;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -28,6 +27,9 @@
     @Autowired
     OtpTmpService otpTmpService;
 
+    @Autowired
+    LoginRecordService loginRecordService;
+
     @Transactional
     public void verifyOtp(VerifyOtpVM verifyOtpParam) {
         verifyOtp(verifyOtpParam.getAccount(), verifyOtpParam.getIndexKey(), verifyOtpParam.getOtpCode());
@@ -37,10 +39,15 @@
     public void verifyOtp(String account, String indexKey, String otpCode) {
     	try {
             if(applicationProperty.isMockLogin()){
+                loginRecordService.saveOTPLoginSuccessRecord(account);
                 log.debug("Do MockLogin");
             } else {  // otp logon
                 OtpResponseDTO otpResponseDTO = otpWebService.verifyOTP(indexKey, otpCode);
-                if (!otpResponseDTO.isSuccess()) {
+                if (otpResponseDTO.isSuccess()) {
+                    loginRecordService.saveOTPLoginSuccessRecord(account);
+                }
+                else {
+                    loginRecordService.saveOTPLoginFailRecord(account, otpResponseDTO.getFailReason());
                     throw new AuthenticationCredentialsNotFoundException("");
                 }
             }

--
Gitblit v1.8.0