04/27 Updated customer invitation allow customer to create username & password
This commit is contained in:
+17
-8
@@ -228,20 +228,29 @@ class CustomerUserForm(FlaskForm):
|
||||
raise ValidationError('Password is required for new accounts.')
|
||||
|
||||
class CustomerInviteForm(FlaskForm):
|
||||
"""Simplified form for creating a customer account via email invitation.
|
||||
"""Form for creating a customer account.
|
||||
|
||||
Only Full Name and Email are required — no username or password.
|
||||
The username is auto-generated from the email address.
|
||||
The customer sets their own password via the emailed link.
|
||||
Admin enters Full Name, Email, Username, and Password on behalf of the
|
||||
customer. The account is immediately active — no emailed setup link
|
||||
is required, though an invitation email is still sent so the customer
|
||||
knows their credentials have been created.
|
||||
"""
|
||||
full_name = StringField('Full Name', validators=[DataRequired(), Length(max=150)])
|
||||
email = StringField('Email', validators=[DataRequired(), Email(), Length(max=255)])
|
||||
full_name = StringField('Full Name', validators=[DataRequired(), Length(max=150)])
|
||||
email = StringField('Email', validators=[DataRequired(), Email(), Length(max=255)])
|
||||
username = StringField('Username', validators=[DataRequired(), Length(min=3, max=100)])
|
||||
password = PasswordField('Password', validators=[DataRequired(), Length(min=8, max=100)])
|
||||
confirm_password = PasswordField('Confirm Password',
|
||||
validators=[DataRequired(),
|
||||
EqualTo('password', message='Passwords must match.')])
|
||||
|
||||
def validate_email(self, field):
|
||||
from app.models.user import User
|
||||
if User.query.filter_by(email=field.data).first():
|
||||
if User.query.filter_by(email=field.data.strip().lower()).first():
|
||||
raise ValidationError('An account with this email address already exists.')
|
||||
|
||||
def validate_username(self, field):
|
||||
if User.query.filter_by(username=field.data.strip()).first():
|
||||
raise ValidationError('This username is already taken.')
|
||||
|
||||
|
||||
class SetPasswordForm(FlaskForm):
|
||||
"""Public form for customer to set their password via emailed link."""
|
||||
|
||||
Reference in New Issue
Block a user