mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
add check for government email addresses
This commit is contained in:
@@ -146,6 +146,26 @@ def check_invited_user_email_address_matches_expected(
|
||||
debug_msg("invited user email did not match expected email, abort(403)")
|
||||
flash("You cannot accept an invite for another person.")
|
||||
abort(403)
|
||||
check_for_gov_email_address(user_email)
|
||||
|
||||
|
||||
def check_for_gov_email_address(user_email):
|
||||
# We could try to check that it is a government email at the time the invite is
|
||||
# sent, but due to the way login.gov allows multiple emails, it would not be effective.
|
||||
# We track the login.gov user by their uuid, so if they have a login.gov account
|
||||
# with a .gov email address and a .com email address, the .com address will work without
|
||||
# having a check here.
|
||||
if (
|
||||
user_email.lower().endswith(".gov")
|
||||
or user_email.lower().endswith(".mil")
|
||||
or user_email.lower().endswith(".si.edu")
|
||||
):
|
||||
# everything is good, proceed
|
||||
pass
|
||||
else:
|
||||
debug_msg("invited user has a non-government email address.")
|
||||
flash("You must use a government email address.")
|
||||
abort(403)
|
||||
|
||||
|
||||
@main.route("/set-up-your-profile", methods=["GET", "POST"])
|
||||
|
||||
Reference in New Issue
Block a user