Skip to content

Commit

Permalink
fix(otp): OTP is required on campus network as well
Browse files Browse the repository at this point in the history
  • Loading branch information
proffapt committed Nov 24, 2023
1 parent e933da4 commit 8c97124
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "iitkgp_erp_login"
version = "2.3.3"
version = "4.4.4"
authors = [
{ name="Arpit Bhardwaj", email="proffapt@pm.me" },
]
Expand Down
29 changes: 13 additions & 16 deletions src/iitkgp_erp_login/erp.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,24 +196,21 @@ def login(
sessionToken=sessionToken
)

# Handling OTP - whether required or not
if is_otp_required():
request_otp(headers=headers, session=session, login_details=login_details, log=LOGGING)

if OTP_CHECK_INTERVAL != None:
try:
if LOGGING: logging.info(" Waiting for OTP ...")
otp = getOTP(OTP_CHECK_INTERVAL)
if LOGGING: logging.info(" Received OTP")

except Exception as e:
raise ErpLoginError(f"Failed to receive OTP: {str(e)}")
else:
otp = input("Enter the OTP sent to your registered email address: ").strip()
# Handling OTP
request_otp(headers=headers, session=session, login_details=login_details, log=LOGGING)

if OTP_CHECK_INTERVAL != None:
try:
if LOGGING: logging.info(" Waiting for OTP ...")
otp = getOTP(OTP_CHECK_INTERVAL)
if LOGGING: logging.info(" Received OTP")

login_details["email_otp"] = otp
except Exception as e:
raise ErpLoginError(f"Failed to receive OTP: {str(e)}")
else:
if LOGGING: logging.info(" OTP is not required!")
otp = input("Enter the OTP sent to your registered email address: ").strip()

login_details["email_otp"] = otp

ssoToken = signin(headers=headers, session=session, login_details=login_details, log=LOGGING)

Expand Down

0 comments on commit 8c97124

Please sign in to comment.