delete the expired ChangeEmail object
This commit is contained in:
parent
cb687c4248
commit
b7cbaa6e84
|
@ -7,26 +7,14 @@
|
|||
{% block single_content %}
|
||||
<div class="card">
|
||||
<div class="card-body p-6">
|
||||
|
||||
{% if incorrect_code %}
|
||||
<div class="text-danger text-center h4">
|
||||
The link is incorrect. <br><br>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
Please go to <a href="{{ url_for('dashboard.setting') }}">settings</a>
|
||||
page to re-send confirmation email.
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if expired_code %}
|
||||
<div class="text-danger text-center h4">
|
||||
The link is already expired. <br><br>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
Please go to <a href="{{ url_for('dashboard.setting') }}">settings</a>
|
||||
page to re-send confirmation email.
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="h3 text-center">Email Update</div>
|
||||
<div class="text-danger text-center h4">
|
||||
Incorrect or expired link. <br><br>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
Please go to <a href="{{ url_for('dashboard.setting') }}">settings</a>
|
||||
page to re-send the confirmation email.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -13,10 +13,13 @@ def change_email():
|
|||
email_change: EmailChange = EmailChange.get_by(code=code)
|
||||
|
||||
if not email_change:
|
||||
return render_template("auth/change_email.html", incorrect_code=True)
|
||||
return render_template("auth/change_email.html")
|
||||
|
||||
if email_change.is_expired():
|
||||
return render_template("auth/change_email.html", expired_code=True)
|
||||
# delete the expired email
|
||||
EmailChange.delete(email_change.id)
|
||||
db.session.commit()
|
||||
return render_template("auth/change_email.html")
|
||||
|
||||
user = email_change.user
|
||||
user.email = email_change.new_email
|
||||
|
|
|
@ -1314,6 +1314,9 @@ class EmailChange(db.Model, ModelMixin):
|
|||
def is_expired(self):
|
||||
return self.expired < arrow.now()
|
||||
|
||||
def __repr__(self):
|
||||
return f"<EmailChange {self.id} {self.new_email} {self.user_id}>"
|
||||
|
||||
|
||||
class AliasUsedOn(db.Model, ModelMixin):
|
||||
"""Used to know where an alias is created"""
|
||||
|
|
Loading…
Reference in New Issue