From 0996378537965affd25adc92e149293260e7e021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Casaj=C3=BAs?= Date: Thu, 1 Dec 2022 09:19:15 +0100 Subject: [PATCH] Revert "Keep the dirty email after registering (#1459)" (#1460) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 0664e3b80cc443233662a58e15fa2938b913eca6. Co-authored-by: Adrià Casajús --- app/api/views/auth.py | 3 +- app/auth/views/change_email.py | 1 - app/auth/views/register.py | 1 - app/dashboard/views/setting.py | 2 -- app/fake_data.py | 2 -- app/models.py | 2 -- .../versions/2022_113018_74fe25b66e9b_.py | 31 ------------------- 7 files changed, 1 insertion(+), 41 deletions(-) delete mode 100644 migrations/versions/2022_113018_74fe25b66e9b_.py diff --git a/app/api/views/auth.py b/app/api/views/auth.py index d186b23f..61d27365 100644 --- a/app/api/views/auth.py +++ b/app/api/views/auth.py @@ -92,7 +92,6 @@ def auth_register(): return jsonify(error="request body cannot be empty"), 400 email = canonicalize_email(data.get("email")) - dirty_email = sanitize_email(data.get("email")) password = data.get("password") if DISABLE_REGISTRATION: @@ -113,7 +112,7 @@ def auth_register(): return jsonify(error="password too long"), 400 LOG.d("create user %s", email) - user = User.create(email=email, dirty_email=dirty_email, name="", password=password) + user = User.create(email=email, name="", password=password) Session.flush() # create activation code diff --git a/app/auth/views/change_email.py b/app/auth/views/change_email.py index 85ed879c..9e70c882 100644 --- a/app/auth/views/change_email.py +++ b/app/auth/views/change_email.py @@ -23,7 +23,6 @@ def change_email(): user = email_change.user user.email = email_change.new_email - user.dirty_email = email_change.dirty_email or email_change.new_email EmailChange.delete(email_change.id) ResetPasswordCode.filter_by(user_id=user.id).delete() diff --git a/app/auth/views/register.py b/app/auth/views/register.py index 47629242..a5c3c966 100644 --- a/app/auth/views/register.py +++ b/app/auth/views/register.py @@ -85,7 +85,6 @@ def register(): LOG.d("create user %s", email) user = User.create( email=email, - dirty_email=sanitized_email, name="", password=form.password.data, referral=get_referral(), diff --git a/app/dashboard/views/setting.py b/app/dashboard/views/setting.py index cf45e616..480fd6cf 100644 --- a/app/dashboard/views/setting.py +++ b/app/dashboard/views/setting.py @@ -57,7 +57,6 @@ from app.utils import ( random_string, CSRFValidationForm, canonicalize_email, - sanitize_email, ) @@ -171,7 +170,6 @@ def setting(): 60 ), # todo: make sure the code is unique new_email=new_email, - dirty_email=sanitize_email(change_email_form.email.data), ) Session.commit() send_change_email_confirmation(current_user, email_change) diff --git a/app/fake_data.py b/app/fake_data.py index a419a371..b5b0d0b9 100644 --- a/app/fake_data.py +++ b/app/fake_data.py @@ -43,7 +43,6 @@ def fake_data(): # Create a user user = User.create( email="john@wick.com", - dirty_email="john@wick.com", name="John Wick", password="password", activated=True, @@ -235,7 +234,6 @@ def fake_data(): user2 = User.create( email="winston@continental.com", - dirty_email="winston@continental.com", password="password", activated=True, referral_id=referral.id, diff --git a/app/models.py b/app/models.py index 12487c6f..bf475e3f 100644 --- a/app/models.py +++ b/app/models.py @@ -320,7 +320,6 @@ class User(Base, ModelMixin, UserMixin, PasswordOracle): FLAG_FREE_OLD_ALIAS_LIMIT = 1 << 2 email = sa.Column(sa.String(256), unique=True, nullable=False) - dirty_email = sa.Column(sa.String(256), unique=False, nullable=True) name = sa.Column(sa.String(128), nullable=True) is_admin = sa.Column(sa.Boolean, nullable=False, default=False) @@ -2065,7 +2064,6 @@ class EmailChange(Base, ModelMixin): index=True, ) new_email = sa.Column(sa.String(256), unique=True, nullable=False) - dirty_email = sa.Column(sa.String(256), unique=False, nullable=True) code = sa.Column(sa.String(128), unique=True, nullable=False) expired = sa.Column(ArrowType, nullable=False, default=_expiration_12h) diff --git a/migrations/versions/2022_113018_74fe25b66e9b_.py b/migrations/versions/2022_113018_74fe25b66e9b_.py deleted file mode 100644 index 7036baa6..00000000 --- a/migrations/versions/2022_113018_74fe25b66e9b_.py +++ /dev/null @@ -1,31 +0,0 @@ -"""empty message - -Revision ID: 74fe25b66e9b -Revises: 2c2093c82bc0 -Create Date: 2022-11-30 18:21:44.235063 - -""" -import sqlalchemy_utils -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '74fe25b66e9b' -down_revision = '2c2093c82bc0' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('email_change', sa.Column('dirty_email', sa.String(length=256), nullable=True)) - op.add_column('users', sa.Column('dirty_email', sa.String(length=256), nullable=True)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('users', 'dirty_email') - op.drop_column('email_change', 'dirty_email') - # ### end Alembic commands ###