Skip to content

Commit

Permalink
Merge branch 'metakgp:main' into minor
Browse files Browse the repository at this point in the history
  • Loading branch information
Dami-18 authored Jul 14, 2024
2 parents 09c9c6a + cafa754 commit b96b413
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ def request_otp():

session = requests.Session()
erp_utils.set_cookie(session, "JSESSIONID", all_fields["sessionToken"])
if not erp.session_alive(session=session):
return ErpResponse(
False, f"Session isn't alive. PLease login again.", status_code=401
).to_response()
erp.request_otp(
headers=headers, session=session, login_details=login_details, log=True
)
Expand Down Expand Up @@ -146,6 +150,10 @@ def login():

session = requests.Session()
erp_utils.set_cookie(session, "JSESSIONID", all_fields["sessionToken"])
if not erp.session_alive(session=session):
return ErpResponse(
False, f"Session isn't alive. PLease login again.", status_code=401
).to_response()
ssoToken = erp.signin(
headers=headers, session=session, login_details=login_details, log=True
)
Expand All @@ -165,12 +173,20 @@ def elective(elective):
"roll_number": data.get("roll_number"),
"ssoToken": request.headers["SSO-Token"],
}

missing = check_missing_fields(all_fields)
if len(missing) > 0:
return ErpResponse(
False, f"Missing Fields: {', '.join(missing)}", status_code=400
).to_response()

session = requests.Session()
erp_utils.set_cookie(session, "ssoToken", all_fields["ssoToken"])
if not erp.session_alive(session=session):
return ErpResponse(
False, f"Session isn't alive. PLease login again.", status_code=401
).to_response()

DEPT = all_fields["roll_number"][2:4]
current_month = datetime.now().month
current_year = datetime.now().year
Expand Down

0 comments on commit b96b413

Please sign in to comment.