Skip to content

Commit

Permalink
fix: #1386 Fix missing user type code while getting requester for loa…
Browse files Browse the repository at this point in the history
…d user information (#1510)
  • Loading branch information
MCatherine1994 authored Jul 29, 2024
1 parent 804a3a5 commit 24e0da2
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions server/backend/api/app/crud/crud_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,10 @@ def update_user_info_from_idim_source(
only for IDIR and Business BCeID users, ignore bc service card users
"""
# get a requester from the database
requester = (
db.query(models.FamUser)
.filter(
models.FamUser.user_name == config.get_requester_name_for_update_user_info()
)
.one_or_none()
requester = get_user_by_domain_and_name(
db, UserType.IDIR, config.get_requester_name_for_update_user_info()
)

# setup IDIM web service
api_instance_env = (
ApiInstanceEnv.PROD if crud_utils.is_on_aws_prod() else ApiInstanceEnv.TEST
Expand All @@ -296,8 +293,12 @@ def update_user_info_from_idim_source(

success_user_list = []
failed_user_list = []
ignored_user_list = [] # we ignore for bcsc users, cause IDIM does not provide bcsc users information
mismatch_user_list = [] # for the users whose user_guid record does not match the user_guid from IDIM
ignored_user_list = (
[]
) # we ignore for bcsc users, cause IDIM does not provide bcsc users information
mismatch_user_list = (
[]
) # for the users whose user_guid record does not match the user_guid from IDIM

for user in fam_users:
try:
Expand All @@ -319,7 +320,11 @@ def update_user_info_from_idim_source(
models.FamUser.user_guid: search_result.get("guid"),
}

if search_result and search_result.get("found") and user.user_guid != search_result.get("guid"):
if (
search_result
and search_result.get("found")
and user.user_guid != search_result.get("guid")
):
# if found user's user_guid does not match our record
# which is the edge case that could cause by the username change, ignore this situation
# only IDIR user has this edge case, because IDIM does not support search IDIR by user_guid
Expand Down

0 comments on commit 24e0da2

Please sign in to comment.