From f0197b5af6232c407085128147ceba1031aaa242 Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Thu, 12 Sep 2019 14:24:43 +0200
Subject: [PATCH] Allow Emails to be 254 characters long.
---
app/auth/forms.py | 28 ++++++++++++++++++----------
app/models.py | 2 +-
migrations/versions/3ca96d906e29_.py | 4 ++--
3 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/app/auth/forms.py b/app/auth/forms.py
index 4a524cfa..02658b62 100644
--- a/app/auth/forms.py
+++ b/app/auth/forms.py
@@ -1,5 +1,6 @@
from flask_wtf import FlaskForm
-from wtforms import StringField, PasswordField, BooleanField, SubmitField, ValidationError, TextAreaField
+from wtforms import (StringField, PasswordField, BooleanField, SubmitField,
+ ValidationError)
from wtforms.validators import DataRequired, Length, Email, Regexp, EqualTo
from ..models import User
@@ -13,13 +14,20 @@ class LoginForm(FlaskForm):
class RegistrationForm(FlaskForm):
email = StringField('Email', validators=[DataRequired(), Email()])
- username = StringField('Username', validators=[
- DataRequired(), Length(1, 64),
- Regexp('^[A-Za-z][A-Za-z0-9_.]*$', 0,
- 'Usernames must have only letters, numbers, dots or '
- 'underscores')])
- password = PasswordField('Password', validators=[
- DataRequired(), EqualTo('password2', message='Passwords must match.')])
+ username = StringField(
+ 'Username',
+ validators=[DataRequired(),
+ Length(1, 64),
+ Regexp('^[A-Za-z][A-Za-z0-9_.]*$',
+ 0,
+ 'Usernames must have only letters, numbers, dots '
+ 'or underscores')]
+ )
+ password = PasswordField(
+ 'Password',
+ validators=[DataRequired(),
+ EqualTo('password2', message='Passwords must match.')]
+ )
password2 = PasswordField('Confirm password', validators=[DataRequired()])
submit = SubmitField('Register')
@@ -79,8 +87,8 @@ class ChangePasswordForm(FlaskForm):
class EditProfileForm(FlaskForm):
- email = StringField('Change Email', validators=[Length(0, 64),
- DataRequired()])
+ email = StringField('Change Email',
+ validators=[Length(0, 254), DataRequired()])
submit = SubmitField('Change Email')
def __init__(self, user, *args, **kwargs):
diff --git a/app/models.py b/app/models.py
index a59a6a95..8da85d64 100644
--- a/app/models.py
+++ b/app/models.py
@@ -107,7 +107,7 @@ class User(UserMixin, db.Model):
# Primary key
id = db.Column(db.Integer, primary_key=True)
confirmed = db.Column(db.Boolean, default=False)
- email = db.Column(db.String(64), unique=True, index=True)
+ email = db.Column(db.String(254), unique=True, index=True)
password_hash = db.Column(db.String(128))
registration_date = db.Column(db.DateTime(), default=datetime.utcnow)
role_id = db.Column(db.Integer, db.ForeignKey('roles.id'))
diff --git a/migrations/versions/3ca96d906e29_.py b/migrations/versions/3ca96d906e29_.py
index bece7894..608dde1e 100644
--- a/migrations/versions/3ca96d906e29_.py
+++ b/migrations/versions/3ca96d906e29_.py
@@ -1,7 +1,7 @@
"""empty message
Revision ID: 3ca96d906e29
-Revises:
+Revises:
Create Date: 2019-09-05 11:43:41.634109
"""
@@ -30,7 +30,7 @@ def upgrade():
op.create_table('users',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('confirmed', sa.Boolean(), nullable=True),
- sa.Column('email', sa.String(length=64), nullable=True),
+ sa.Column('email', sa.String(length=254), nullable=True),
sa.Column('password_hash', sa.String(length=128), nullable=True),
sa.Column('registration_date', sa.DateTime(), nullable=True),
sa.Column('role_id', sa.Integer(), nullable=True),