保誠-保戶業務員媒合平台
[UPDATE] 客戶登入發送手機/email驗證碼的時候須加上img code驗證碼避免重複發送簡訊的問題
修改1個檔案
33 ■■■■■ 已變更過的檔案
pamapi/src/main/java/com/pollex/pam/web/rest/OtpResource.java 33 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/web/rest/OtpResource.java
@@ -73,8 +73,23 @@
    @Autowired
    CustomerRepository customerRepository;
    @PostMapping("/sendOtp")
    public ResponseEntity<Object> sendOtp(@RequestBody OtpLoginVM login) {
    @PostMapping("/sendOtp/{imgCode}")
    public ResponseEntity<Object> sendOtp(@RequestBody OtpLoginVM login
            , @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)) {
            throw new OtpLoginFailException("驗證碼輸入錯誤");
        }
        if(!imgCode.equals(sessionImpCode)) {
            throw new OtpLoginFailException("驗證碼輸入錯誤");
        }
        OtpResponseDTO otpResponse;
        if(applicationProperty.isMockLogin()) {
            otpResponse = getMockSendOtpResponse();
@@ -91,20 +106,10 @@
    }
    @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)) {
            throw new OtpLoginFailException("驗證碼輸入錯誤");
        }
        if(!imgCode.equals(sessionImpCode)) {
            throw new OtpLoginFailException("驗證碼輸入錯誤");
        }
        
        otpUtilService.verifyOtp(verifyOtpParam);