Skip to content

Commit

Permalink
Chore: more logging around user lookup logic (#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
angela-tran authored Dec 18, 2024
2 parents c215e8c + 7c950fa commit 012d916
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions eligibility_server/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,25 @@ def _check_user(self, sub, name, types):
if len(types) < 1:
logger.debug("List of types to check was empty.")
return []
else:
logger.debug(f"Types to check: {types}")

if self.hash:
sub = self.hash.hash_input(sub)
name = self.hash.hash_input(name)

logger.debug(f"Hashed sub, name: {sub},{name}")

existing_user = User.query.filter_by(sub=sub, name=name).first()
if existing_user:
existing_user_types = [type.name for type in existing_user.types]
logger.debug(f"Existing types on user: {existing_user_types}")
else:
existing_user_types = []
logger.debug("User not found")

matching_types = set(existing_user_types) & set(types)
logger.debug(f"Matching types: {matching_types}")

if existing_user is None:
logger.debug("Database does not contain requested user.")
Expand All @@ -123,6 +130,7 @@ def _check_user(self, sub, name, types):
logger.debug(f"User's types do not contain any of the requested types: {types}")
return []
else:
logger.debug("Returning matching types for existing user")
return list(matching_types)

def get(self):
Expand Down

0 comments on commit 012d916

Please sign in to comment.