From 0c20922583a12f10423887c4e2f6d4ebf225dd17 Mon Sep 17 00:00:00 2001 From: Michael Drury <mpdrury15@gmail.com> Date: Tue, 9 May 2023 14:41:39 +0100 Subject: [PATCH] fixed error with email regex which didnt require a . --- shop/forms.py | 4 ++-- shop/templates/user_page.html | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/shop/forms.py b/shop/forms.py index 0ac096d..a8b371d 100644 --- a/shop/forms.py +++ b/shop/forms.py @@ -13,7 +13,7 @@ class SignupForm(FlaskForm): username = StringField('Username', validators=[input_required(), Length(1, 12)]) password = PasswordField('Password', validators=[input_required()]) verifyPassword = PasswordField('Verify password', validators=[input_required(), EqualTo('password', message='Passwords must match')]) - email = StringField('email', validators=[Regexp(regex="^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$", message = 'has to be a valid email'), input_required()]) + email = StringField('email', validators=[Regexp(regex="[^@]+@[^@]+.[^@]+", message = 'has to be a valid email'), input_required()]) mobile = StringField('mobile', validators=[Regexp(regex='^[+-]?[0-9]+$', message = 'only integers allowed'), input_required(), Length(11, 11)]) submit = SubmitField('Submit') @@ -52,7 +52,7 @@ class reviewForm(FlaskForm): submit1 = SubmitField('Submit') class emailChangeForm(FlaskForm): - new_email = StringField('Enter a new email:', validators=[Regexp(regex="^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$", message = 'has to be a valid email'), input_required()]) + new_email = StringField('Enter a new email:', validators=[Regexp(regex="[^@]+@[^@]+.[^@]+", message = 'has to be a valid email'), input_required()]) submit1 = SubmitField('Submit') class mobileChangeForm(FlaskForm): diff --git a/shop/templates/user_page.html b/shop/templates/user_page.html index f572cdf..9cfc62d 100644 --- a/shop/templates/user_page.html +++ b/shop/templates/user_page.html @@ -34,6 +34,7 @@ </p> <p class="login_field"> {{ mobile_form.new_mobile.label }} {{ mobile_form.new_mobile(class = "input_field") }} {{ mobile_form.submit2(class = "input_field") }} + </p> </div> </form> -- GitLab