|
@@ -372,6 +372,8 @@ class VfsPlugin(IVSPlg):
|
|
|
"captcha_api_key": cf_token
|
|
"captcha_api_key": cf_token
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ now_utc = datetime.utcnow()
|
|
|
|
|
+ sent_at = now_utc.strftime("%Y-%m-%d %H:%M:%S")
|
|
|
self._log("Sending Login Request via Browser Fetch...")
|
|
self._log("Sending Login Request via Browser Fetch...")
|
|
|
resp = self._perform_request("POST", url, headers=headers, json_data=data)
|
|
resp = self._perform_request("POST", url, headers=headers, json_data=data)
|
|
|
resp_json = resp.json()
|
|
resp_json = resp.json()
|
|
@@ -386,7 +388,7 @@ class VfsPlugin(IVSPlg):
|
|
|
self._log("Login requires OTP.")
|
|
self._log("Login requires OTP.")
|
|
|
# 注意:_submit_login_otp 内部也会调用 _refresh_turnstile_token
|
|
# 注意:_submit_login_otp 内部也会调用 _refresh_turnstile_token
|
|
|
# 所以这里旧的 cf_token 其实用处不大,传过去也没事
|
|
# 所以这里旧的 cf_token 其实用处不大,传过去也没事
|
|
|
- otp = self._read_otp_email()
|
|
|
|
|
|
|
+ otp = self._read_otp_email(sent_at=sent_at)
|
|
|
self._submit_login_otp(cf_token, otp)
|
|
self._submit_login_otp(cf_token, otp)
|
|
|
|
|
|
|
|
else:
|
|
else:
|
|
@@ -794,17 +796,18 @@ class VfsPlugin(IVSPlg):
|
|
|
resp = self._perform_request("GET", url, headers=headers)
|
|
resp = self._perform_request("GET", url, headers=headers)
|
|
|
return resp.json()
|
|
return resp.json()
|
|
|
|
|
|
|
|
- def _read_otp_email(self, sender='donotreply at vfshelpline.com') -> str:
|
|
|
|
|
|
|
+ def _read_otp_email(self, sent_at='', sender='VFS Global') -> str:
|
|
|
# 保持原样,这部分使用云API读取邮件,不依赖本地网络库
|
|
# 保持原样,这部分使用云API读取邮件,不依赖本地网络库
|
|
|
master_email = "visafly666@gmail.com"
|
|
master_email = "visafly666@gmail.com"
|
|
|
recipient = self.config.account.username
|
|
recipient = self.config.account.username
|
|
|
subject_keywords = "One Time Password"
|
|
subject_keywords = "One Time Password"
|
|
|
body_keywords = "OTP"
|
|
body_keywords = "OTP"
|
|
|
- now_utc = datetime.utcnow()
|
|
|
|
|
- formatted_utc_time = now_utc.strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
|
|
|
+ if not sent_at:
|
|
|
|
|
+ now_utc = datetime.utcnow()
|
|
|
|
|
+ sent_at = now_utc.strftime("%Y-%m-%d %H:%M:%S")
|
|
|
self._log(f"Waiting for OTP email...")
|
|
self._log(f"Waiting for OTP email...")
|
|
|
content_out = VSCloudApi.Instance().fetch_mail_content(
|
|
content_out = VSCloudApi.Instance().fetch_mail_content(
|
|
|
- master_email, sender, recipient, subject_keywords, body_keywords, formatted_utc_time, 300
|
|
|
|
|
|
|
+ master_email, sender, recipient, subject_keywords, body_keywords, sent_at, 300
|
|
|
)
|
|
)
|
|
|
if content_out:
|
|
if content_out:
|
|
|
match = re.search(r'\b\d{6}\b', content_out)
|
|
match = re.search(r'\b\d{6}\b', content_out)
|
|
@@ -983,11 +986,13 @@ class VfsPlugin(IVSPlg):
|
|
|
otp_enabled = sub_conf.get("isApplicantOTPEnabled", False)
|
|
otp_enabled = sub_conf.get("isApplicantOTPEnabled", False)
|
|
|
if otp_enabled:
|
|
if otp_enabled:
|
|
|
self._log("Applicant OTP Required.")
|
|
self._log("Applicant OTP Required.")
|
|
|
|
|
+ now_utc = datetime.utcnow()
|
|
|
|
|
+ sent_at = now_utc.strftime("%Y-%m-%d %H:%M:%S")
|
|
|
if not self._applicant_otp_send(apt_config, final_urn):
|
|
if not self._applicant_otp_send(apt_config, final_urn):
|
|
|
raise BizLogicError(message='Applicant OTP send failed')
|
|
raise BizLogicError(message='Applicant OTP send failed')
|
|
|
|
|
|
|
|
# 复用之前的读邮件逻辑
|
|
# 复用之前的读邮件逻辑
|
|
|
- otp_code = self._read_otp_email(sender='donotreply at vfsglobal.com')
|
|
|
|
|
|
|
+ otp_code = self._read_otp_email(sent_at=sent_at)
|
|
|
if not self._applicant_otp_verify(apt_config, final_urn, otp_code):
|
|
if not self._applicant_otp_verify(apt_config, final_urn, otp_code):
|
|
|
raise BizLogicError(message='Applicant OTP verify failed')
|
|
raise BizLogicError(message='Applicant OTP verify failed')
|
|
|
|
|
|