保誠-保戶業務員媒合平台
Jack
2021-11-26 6282fdfadbc9f22e3874f206cdd5e67014583991
[UPDATE] 補推前一版本缺少的檔案
新增1個檔案
41 ■■■■■ 已變更過的檔案
pamapi/src/main/java/com/pollex/pam/service/OtpUtilService.java 41 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/OtpUtilService.java
比對新檔案
@@ -0,0 +1,41 @@
package com.pollex.pam.service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException;
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;
@Service
public class OtpUtilService {
    private static final Logger log = LoggerFactory.getLogger(OtpUtilService.class);
    @Autowired
    ApplicationProperties applicationProperty;
    @Autowired
    OtpWebService otpWebService;
    public void verifyOtp(String indexKey, String otpCode) {
        if(applicationProperty.isMockLogin()){
            return;
        }
        try {
            OtpResponseDTO otpResponseDTO = otpWebService.verifyOTP(indexKey, otpCode);
            if (!otpResponseDTO.isSuccess()) {
                throw new AuthenticationCredentialsNotFoundException("");
            }
        } catch (Exception e) {
            log.error("Exception: ", e);
            throw new AuthenticationCredentialsNotFoundException("");
        }
    }
}