Revert "Keep the dirty email after registering (#1459)" (#1460)

This reverts commit 0664e3b80c.

Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
This commit is contained in:
Adrià Casajús 2022-12-01 09:19:15 +01:00 committed by GitHub
parent 0664e3b80c
commit 0996378537
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 1 additions and 41 deletions

View File

@ -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

View File

@ -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()

View File

@ -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(),

View File

@ -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)

View File

@ -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,

View File

@ -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)

View File

@ -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 ###