11from requests import Session
22from bs4 import BeautifulSoup , Tag
33import re
4+ from typing import Any
45
56import config
67import totp
8+ from helpers import send_request
79
810
911def login_with_drexel_connect (session : Session ) -> Session :
10- response = session . get ( config .drexel_connect_base_url )
12+ response = send_request ( session , config .drexel_connect_base_url , method = "GET" )
1113 soup = BeautifulSoup (response .text , "html.parser" )
1214
1315 csrf_token = extract_csrf_token (soup )
@@ -21,26 +23,20 @@ def login_with_drexel_connect(session: Session) -> Session:
2123 }
2224
2325 # this should send the credentials and send the MFA request
24- response = session .post (
25- config .drexel_connect_base_url + form_action_path , data = login_payload
26- )
26+ response = send_request (session , config .drexel_connect_base_url + form_action_path , data = login_payload , method = "POST" )
2727
2828 soup = BeautifulSoup (response .text , "html.parser" )
2929 data = parse_initial_mfa_page (soup )
3030
31- response = session .post (
32- config .drexel_connect_base_url + data ["url" ], data = data ["form-data" ]
33- )
31+ response = send_request (session , config .drexel_connect_base_url + data ["url" ], data = data ["form-data" ], method = "POST" )
3432 json_response = response .json ()
3533
3634 data = {
3735 json_response ["csrfN" ]: json_response ["csrfV" ],
3836 "_eventId" : json_response ["actValue" ],
3937 }
4038
41- response = session .post (
42- config .drexel_connect_base_url + json_response ["flowExURL" ], data = data
43- )
39+ response = send_request (session , config .drexel_connect_base_url + json_response ["flowExURL" ], data = data , method = "POST" )
4440 soup = BeautifulSoup (response .text , "html.parser" )
4541
4642 parsed_data = parse_final_mfa_page (soup )
@@ -53,10 +49,10 @@ def login_with_drexel_connect(session: Session) -> Session:
5349 "j_mfaToken" : totp_code ,
5450 }
5551
56- response = session .post (
57- config .drexel_connect_base_url + parsed_data ["url" ], data = data
58- )
59-
52+ # session.post(
53+ # config.drexel_connect_base_url + parsed_data["url"], data=data
54+ # )
55+ send_request ( session , config . drexel_connect_base_url + parsed_data [ "url" ], data = data , method = "POST" )
6056 return session
6157
6258
@@ -98,7 +94,7 @@ def extract_form_action_path(soup: BeautifulSoup) -> str:
9894 return form_action_path
9995
10096
101- def parse_initial_mfa_page (soup : BeautifulSoup ) -> dict [str , str ]:
97+ def parse_initial_mfa_page (soup : BeautifulSoup ) -> dict [str , Any ]:
10298 data = {}
10399
104100 # get the first script tag that isn't empty
0 commit comments