Skip to content

Commit 7dd36ef

Browse files
tsdg112mrooney
andauthored
prevent email MFA check from marking messages as read (#568)
* prevent email MFA check from marking messages as read * lint * fix quotation marks * lint * Use correct tag in xpath * New MFA email subject line Co-authored-by: Michael Rooney <mrooney@users.noreply.github.com>
1 parent 2401017 commit 7dd36ef

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

mintapi/signIn.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def get_email_code(imap_account, imap_password, imap_server, imap_folder, delete
110110
count = count + 1
111111
if count > 3:
112112
break
113-
rv, data = imap_client.fetch(num, "(RFC822)")
113+
rv, data = imap_client.fetch(num, "(BODY.PEEK[])")
114114
if rv != "OK":
115115
raise RuntimeError("Unable to complete due to error message: " + rv)
116116

@@ -130,7 +130,7 @@ def get_email_code(imap_account, imap_password, imap_server, imap_folder, delete
130130
p = re.search(r"(\d\d\d\d\d\d) Mint code", subject)
131131
if p:
132132
code = p.group(1)
133-
elif not re.search("Your Mint Account", subject, re.IGNORECASE):
133+
elif not re.search("Your Mint (code|Account)", subject, re.IGNORECASE):
134134
continue
135135
else:
136136
code = ""
@@ -530,6 +530,21 @@ def handle_login_failures(driver):
530530
except TimeoutException:
531531
pass
532532

533+
try:
534+
WebDriverWait(driver, 0).until(
535+
expected_conditions.presence_of_element_located(
536+
(
537+
By.XPATH,
538+
'//h2[contains(text(), "The feature you\'ve requested is temporarily unavailable")]',
539+
)
540+
)
541+
)
542+
raise RuntimeError(
543+
"Login to Mint failed: Mint reports that it's temporarily unavailable: you may be blocked."
544+
)
545+
except TimeoutException:
546+
pass
547+
533548

534549
def bypass_verified_user_page(driver):
535550
# bypass "Let's add your current mobile number" interstitial page

0 commit comments

Comments
 (0)