Skip to content

Commit

Permalink
set userid to string
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-XT committed May 19, 2024
1 parent 5a1b359 commit 255ecf3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions MagicalAuth.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ def send_magic_link(self, otp, ip_address):
session.close()
if user is None:
raise HTTPException(status_code=404, detail="User not found")
self.token = encrypt(passphrase=f"{self.encryption_key}{user.id}", data=user.id)
self.token = encrypt(
passphrase=f"{self.encryption_key}{str(user.id)}", data=str(user.id)
)
if not pyotp.TOTP(user.mfa_token).verify(otp):
self.add_failed_login(ip_address=ip_address)
raise HTTPException(
Expand Down Expand Up @@ -173,7 +175,9 @@ def login(self, ip_address):
status_code=429,
detail="Too many failed login attempts today. Please try again tomorrow.",
)
user_id = decrypt(passphrase=f"{self.encryption_key}{user.id}", data=self.token)
user_id = decrypt(
passphrase=f"{self.encryption_key}{str(user.id)}", data=self.token
)
if str(user.id) == user_id:
return user
self.add_failed_login(ip_address=ip_address)
Expand Down
2 changes: 1 addition & 1 deletion UI.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def login_page():
auth.send_magic_link(otp=otp)
else:
st.write("Invalid MFA token. Please try again.")
st.rerun()
st.stop()


try:
Expand Down

0 comments on commit 255ecf3

Please sign in to comment.