mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-29 13:18:34 -04:00
Guess people’s names when they’re invited
Most people’s names, especially in government are in the format firstname.lastname@department.gov.uk. This means that you can pretty reliably guess that their name is ‘Firstname Lastname’. When users are invited to Notify we know their email address already. So this commit pre-populates the registration form based on this guess. This is a nice little detail, but it should also stop the browser pre-filling the name field with someone’s email address (which I think happens because the browser assumes a registration form will have an email field).
This commit is contained in:
@@ -41,6 +41,7 @@ from app.main.validators import (
|
||||
ValidGovEmail,
|
||||
)
|
||||
from app.notify_client.models import roles
|
||||
from app.utils import guess_name_from_email_address
|
||||
|
||||
|
||||
def get_time_value_and_label(future_time):
|
||||
@@ -215,20 +216,18 @@ class RegisterUserForm(StripWhitespaceForm):
|
||||
auth_type = HiddenField('auth_type', default='sms_auth')
|
||||
|
||||
|
||||
class RegisterUserFromInviteForm(StripWhitespaceForm):
|
||||
class RegisterUserFromInviteForm(RegisterUserForm):
|
||||
def __init__(self, invited_user):
|
||||
super().__init__(
|
||||
service=invited_user['service'],
|
||||
email_address=invited_user['email_address'],
|
||||
auth_type=invited_user['auth_type'],
|
||||
name=guess_name_from_email_address(
|
||||
invited_user['email_address']
|
||||
),
|
||||
)
|
||||
|
||||
name = StringField(
|
||||
'Full name',
|
||||
validators=[DataRequired(message='Can’t be empty')]
|
||||
)
|
||||
mobile_number = InternationalPhoneNumber('Mobile number', validators=[])
|
||||
password = password()
|
||||
service = HiddenField('service')
|
||||
email_address = HiddenField('email_address')
|
||||
auth_type = HiddenField('auth_type', validators=[DataRequired()])
|
||||
|
||||
Reference in New Issue
Block a user