fix change email in settings
This commit is contained in:
parent
b08b584102
commit
83c2bb2b23
|
@ -61,8 +61,11 @@ def setting():
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
if request.form.get("form-name") == "update-email":
|
if request.form.get("form-name") == "update-email":
|
||||||
if change_email_form.validate():
|
if change_email_form.validate():
|
||||||
if form.email.data != current_user.email and not pending_email:
|
if (
|
||||||
new_email = form.email.data
|
change_email_form.email.data != current_user.email
|
||||||
|
and not pending_email
|
||||||
|
):
|
||||||
|
new_email = change_email_form.email.data
|
||||||
|
|
||||||
# check if this email is not already used
|
# check if this email is not already used
|
||||||
if (
|
if (
|
||||||
|
@ -90,6 +93,7 @@ def setting():
|
||||||
"A confirmation email is on the way, please check your inbox",
|
"A confirmation email is on the way, please check your inbox",
|
||||||
"success",
|
"success",
|
||||||
)
|
)
|
||||||
|
return redirect(url_for("dashboard.setting"))
|
||||||
if request.form.get("form-name") == "update-profile":
|
if request.form.get("form-name") == "update-profile":
|
||||||
if form.validate():
|
if form.validate():
|
||||||
profile_updated = False
|
profile_updated = False
|
||||||
|
@ -116,9 +120,15 @@ def setting():
|
||||||
|
|
||||||
if profile_updated:
|
if profile_updated:
|
||||||
flash(f"Your profile has been updated", "success")
|
flash(f"Your profile has been updated", "success")
|
||||||
|
return redirect(url_for("dashboard.setting"))
|
||||||
|
|
||||||
elif request.form.get("form-name") == "change-password":
|
elif request.form.get("form-name") == "change-password":
|
||||||
|
flash(
|
||||||
|
"You are going to receive an email containing instructions to change your password",
|
||||||
|
"success",
|
||||||
|
)
|
||||||
send_reset_password_email(current_user)
|
send_reset_password_email(current_user)
|
||||||
|
return redirect(url_for("dashboard.setting"))
|
||||||
|
|
||||||
elif request.form.get("form-name") == "notification-preference":
|
elif request.form.get("form-name") == "notification-preference":
|
||||||
choose = request.form.get("notification")
|
choose = request.form.get("notification")
|
||||||
|
@ -128,6 +138,7 @@ def setting():
|
||||||
current_user.notification = False
|
current_user.notification = False
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash("Your notification preference has been updated", "success")
|
flash("Your notification preference has been updated", "success")
|
||||||
|
return redirect(url_for("dashboard.setting"))
|
||||||
|
|
||||||
elif request.form.get("form-name") == "delete-account":
|
elif request.form.get("form-name") == "delete-account":
|
||||||
User.delete(current_user.id)
|
User.delete(current_user.id)
|
||||||
|
@ -142,6 +153,7 @@ def setting():
|
||||||
current_user.alias_generator = scheme
|
current_user.alias_generator = scheme
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash("Your preference has been updated", "success")
|
flash("Your preference has been updated", "success")
|
||||||
|
return redirect(url_for("dashboard.setting"))
|
||||||
|
|
||||||
elif request.form.get("form-name") == "export-data":
|
elif request.form.get("form-name") == "export-data":
|
||||||
data = {
|
data = {
|
||||||
|
@ -171,8 +183,6 @@ def setting():
|
||||||
headers={"Content-Disposition": "attachment;filename=data.json"},
|
headers={"Content-Disposition": "attachment;filename=data.json"},
|
||||||
)
|
)
|
||||||
|
|
||||||
return redirect(url_for("dashboard.setting"))
|
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"dashboard/setting.html",
|
"dashboard/setting.html",
|
||||||
form=form,
|
form=form,
|
||||||
|
@ -198,11 +208,6 @@ def send_reset_password_email(user):
|
||||||
|
|
||||||
email_utils.send_reset_password_email(user.email, user.name, reset_password_link)
|
email_utils.send_reset_password_email(user.email, user.name, reset_password_link)
|
||||||
|
|
||||||
flash(
|
|
||||||
"You are going to receive an email containing instructions to change your password",
|
|
||||||
"success",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def send_change_email_confirmation(user: User, email_change: EmailChange):
|
def send_change_email_confirmation(user: User, email_change: EmailChange):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue