Skip to content

Commit

Permalink
Improve justice email validation
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljcollinsuk committed Jan 10, 2025
1 parent c2d5c79 commit 2328f89
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion controlpanel/oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def create_user(self, claims):
"email": claims.get(settings.OIDC_FIELD_EMAIL),
"name": self.normalise_name(claims.get(settings.OIDC_FIELD_NAME)),
}
if user_details["email"].endswith("justice.gov.uk"):
email_domain = user_details["email"].split("@")[-1]
if email_domain in settings.JUSTICE_EMAIL_DOMAINS:
user_details["justice_email"] = user_details["email"]

return User.objects.create(**user_details)
Expand Down
2 changes: 2 additions & 0 deletions controlpanel/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@
OIDC_FIELD_USERNAME = "nickname"
OIDC_STORE_ID_TOKEN = True

JUSTICE_EMAIL_DOMAINS = ["justice.gov.uk", "cica.justice.gov.uk"]

# Auth0
AUTH0 = {
"client_id": OIDC_RP_CLIENT_ID,
Expand Down

0 comments on commit 2328f89

Please sign in to comment.