Skip to content

Commit

Permalink
Avoid sending raw error to user
Browse files Browse the repository at this point in the history
  • Loading branch information
jingcheng16 committed Apr 24, 2024
1 parent 4069f88 commit 8871bad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions corehq/apps/sso/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@ def auto_deactivate_removed_sso_users():
continue
except Exception as e:
notify_exception(None, f"Failed to get members of the IdP. {str(e)}")
send_deactivation_skipped_email(idp=idp, failure_code=MSGraphIssue.VERIFICATION_ERROR,
error="verification error",
error_description={str(e)})
send_deactivation_skipped_email(idp=idp, failure_code=MSGraphIssue.OTHER_ERROR)
continue

# if the Graph Users API returns an empty list of users we will skip auto deactivation
Expand Down Expand Up @@ -186,6 +184,8 @@ def send_deactivation_skipped_email(idp, failure_code, error=None, error_descrip
"indicates an issue with Microsoft's servers.")
elif failure_code == MSGraphIssue.EMPTY_ERROR:
failure_reason = _("We received an empty list of users from your Microsoft Entra ID instance.")
elif failure_code == MSGraphIssue.OTHER_ERROR:
failure_reason = _("We encountered an unknown issue, please contact Commcare HQ Support.")

context = get_sso_deactivation_skip_email_context(idp, failure_reason)
for send_to in context["to"]:
Expand Down
1 change: 1 addition & 0 deletions corehq/apps/sso/utils/entra.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class MSGraphIssue:
HTTP_ERROR = "http_error"
VERIFICATION_ERROR = "verification_error"
EMPTY_ERROR = "empty_error"
OTHER_ERROR = "other_error"


def get_all_members_of_the_idp_from_entra(idp):
Expand Down

0 comments on commit 8871bad

Please sign in to comment.