mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 07:46:23 -04:00
Be strict about similar email addresses for alerts
We don’t want a single person to have two accounts on an emergency alerts service because it would let them circumvent the two eyes approval process. We can go some way to mitigating against this by stopping people using common methods that email providers use to alias email addresses. These are: - being case insensitive - being insensitive to the position or number of dots in the local part of an email address - using ‘plus addressing’ We already prevent the first one, this commit adds normalisation which strip out the second two before doing the comparision with the current user’s email address.
This commit is contained in:
@@ -62,6 +62,7 @@ from app.models.roles_and_permissions import (
|
||||
roles,
|
||||
)
|
||||
from app.utils import merge_jsonlike
|
||||
from app.utils.user import distinct_email_addresses
|
||||
|
||||
|
||||
def get_time_value_and_label(future_time):
|
||||
@@ -1060,6 +1061,10 @@ class InviteUserForm(BaseInviteUserForm, PermissionsForm):
|
||||
class BroadcastInviteUserForm(BaseInviteUserForm, BroadcastPermissionsForm):
|
||||
email_address = email_address(gov_user=True)
|
||||
|
||||
def validate_email_address(self, field):
|
||||
if not distinct_email_addresses(field.data, self.invalid_email_address):
|
||||
raise ValidationError("You cannot send an invitation to yourself")
|
||||
|
||||
|
||||
class InviteOrgUserForm(StripWhitespaceForm):
|
||||
email_address = email_address(gov_user=False)
|
||||
|
||||
Reference in New Issue
Block a user