Skip to content

Commit

Permalink
Added unique email validator to AddEmailForm
Browse files Browse the repository at this point in the history
  • Loading branch information
lingthio committed Jun 10, 2014
1 parent 396b1ec commit 3c38c17
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions flask_user/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ def unique_username_validator(form, field):
""" Username must be unique"""
user_manager = current_app.user_manager
if not user_manager.username_is_available(field.data):
raise ValidationError(_('This Username is no longer available. Please try another one.'))
raise ValidationError(_('This Username is already in use. Please try another one.'))


def unique_email_validator(form, field):
""" Username must be unique"""
user_manager = current_app.user_manager
if not user_manager.email_is_available(field.data):
raise ValidationError(_('This Email is no longer available. Please try another one.'))
raise ValidationError(_('This Email is already in use. Please try another one.'))

# ***********
# ** Forms **
Expand All @@ -65,8 +65,8 @@ def unique_email_validator(form, field):
class AddEmailForm(Form):
email = StringField(_('Email'), validators=[
validators.Required(_('Email is required')),
validators.Email(_('Invalid Email'))
])
validators.Email(_('Invalid Email')),
unique_email_validator])
submit = SubmitField(_('Add Email'))

class ChangePasswordForm(Form):
Expand Down

0 comments on commit 3c38c17

Please sign in to comment.