Skip to content

Commit

Permalink
fix(ooniauth): bypass Nonetype check to return None (#857)
Browse files Browse the repository at this point in the history
  • Loading branch information
DecFox authored Jul 9, 2024
1 parent f04f855 commit 578d8ad
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions ooniapi/services/ooniauth/src/ooniauth/routers/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,25 +120,24 @@ def maybe_get_user_session_from_header(
token = get_client_token(
authorization=authorization_header, jwt_encryption_key=jwt_encryption_key
)
email_address = token["email_address"]
account_id = token["account_id"]
role = get_account_role(admin_emails=admin_emails, email_address=email_address)
login_time = datetime.fromtimestamp(token["login_time"])
redirect_to = ""

return UserSession(
session_token="",
redirect_to=redirect_to,
email_address=email_address,
account_id=account_id,
role=role,
login_time=login_time,
is_logged_in=True,
)
except:
return None

email_address = token["email_address"]
account_id = token["account_id"]
role = get_account_role(admin_emails=admin_emails, email_address=email_address)
login_time = datetime.fromtimestamp(token["login_time"])
redirect_to = ""

return UserSession(
session_token="",
redirect_to=redirect_to,
email_address=email_address,
account_id=account_id,
role=role,
login_time=login_time,
is_logged_in=True,
)


def get_user_session_from_login_token(
login_token: str, jwt_encryption_key: str, hashing_key: str, admin_emails: List[str]
Expand Down

0 comments on commit 578d8ad

Please sign in to comment.