Fix migration script and LGTM

This commit is contained in:
Khanh Ngo 2019-12-21 22:26:56 +07:00
parent 7739bf7cfc
commit 4bdd433079
No known key found for this signature in database
GPG Key ID: A945965CD6351844
5 changed files with 10 additions and 10 deletions

View File

@ -17,12 +17,10 @@ depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('user', sa.Column('confirmed', sa.Boolean(), nullable=True))
# ### end Alembic commands ###
with op.batch_alter_table('user') as batch_op:
batch_op.add_column(sa.Column('confirmed', sa.Boolean()))
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('user', 'confirmed')
# ### end Alembic commands ###
with op.batch_alter_table('user') as batch_op:
batch_op.drop_column('confirmed')

View File

@ -26,7 +26,7 @@ class User(db.Model):
lastname = db.Column(db.String(64))
email = db.Column(db.String(128))
otp_secret = db.Column(db.String(16))
confirmed = db.Column(db.Boolean, default=False)
confirmed = db.Column(db.SmallInteger, default=0)
role_id = db.Column(db.Integer, db.ForeignKey('role.id'))
def __init__(self,

View File

@ -446,7 +446,7 @@ def confirm_email(token):
return render_template('email_confirmation.html', status=2)
else:
# Confirm email is valid
user.update_confirmed(confirmed=True)
user.update_confirmed(confirmed=1)
current_app.logger.info(
"User email {} confirmed successfully".format(email))
return render_template('email_confirmation.html', status=1)

View File

@ -13,6 +13,7 @@ def confirm_token(token, expiration=86400):
email = serializer.loads(token,
salt=current_app.config['SALT'],
max_age=expiration)
except:
except Exception as e:
current_app.logger.debug(e)
return False
return email

View File

@ -157,6 +157,7 @@
bgcolor="#3498db"> <a
href="{{ verification_link }}"
target="_blank"
rel="noopener noreferrer"
style="border: solid 1px #3498db; border-radius: 5px; box-sizing: border-box; cursor: pointer; display: inline-block; font-size: 14px; font-weight: bold; margin: 0; padding: 12px 25px; text-decoration: none; text-transform: capitalize; background-color: #3498db; border-color: #3498db; color: #ffffff;">Verify
Email Address</a> </td>
</tr>
@ -194,7 +195,7 @@
<span class="apple-link"
style="color: #999999; font-size: 12px; text-align: center;">This email was sent
from <a href="{{ SETTING.get('site_url') }}"
target="_blank">{{ SITE_NAME }}</a></span>
target="_blank" rel="noopener noreferrer">{{ SITE_NAME }}</a></span>
</td>
</tr>
<tr>