mirror of
https://github.com/simple-login/app.git
synced 2024-09-29 21:21:29 +02:00
only display profile updated message when something changes
This commit is contained in:
parent
d061ad7d56
commit
8889dc119f
@ -49,8 +49,12 @@ def setting():
|
|||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
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
|
||||||
# update user info
|
# update user info
|
||||||
|
if form.name.data != current_user.name:
|
||||||
current_user.name = form.name.data
|
current_user.name = form.name.data
|
||||||
|
db.session.commit()
|
||||||
|
profile_updated = True
|
||||||
|
|
||||||
if form.profile_picture.data:
|
if form.profile_picture.data:
|
||||||
file_path = random_string(30)
|
file_path = random_string(30)
|
||||||
@ -64,12 +68,17 @@ def setting():
|
|||||||
LOG.d("upload file %s to s3", file)
|
LOG.d("upload file %s to s3", file)
|
||||||
|
|
||||||
current_user.profile_picture_id = file.id
|
current_user.profile_picture_id = file.id
|
||||||
db.session.flush()
|
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
profile_updated = True
|
||||||
|
|
||||||
|
if profile_updated:
|
||||||
flash(f"Your profile has been updated", "success")
|
flash(f"Your profile has been updated", "success")
|
||||||
|
|
||||||
if form.email.data and form.email.data != current_user.email:
|
if (
|
||||||
|
form.email.data
|
||||||
|
and form.email.data != current_user.email
|
||||||
|
and not pending_email
|
||||||
|
):
|
||||||
new_email = form.email.data
|
new_email = form.email.data
|
||||||
|
|
||||||
# check if this email is not used by other user, or as alias
|
# check if this email is not used by other user, or as alias
|
||||||
@ -94,6 +103,10 @@ def setting():
|
|||||||
)
|
)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
send_change_email_confirmation(current_user, email_change)
|
send_change_email_confirmation(current_user, email_change)
|
||||||
|
flash(
|
||||||
|
"A confirmation email is on the way, please check your inbox",
|
||||||
|
"success",
|
||||||
|
)
|
||||||
|
|
||||||
elif request.form.get("form-name") == "change-password":
|
elif request.form.get("form-name") == "change-password":
|
||||||
send_reset_password_email(current_user)
|
send_reset_password_email(current_user)
|
||||||
@ -138,8 +151,6 @@ def send_change_email_confirmation(user: User, email_change: EmailChange):
|
|||||||
|
|
||||||
email_utils.send_change_email(email_change.new_email, user.email, user.name, link)
|
email_utils.send_change_email(email_change.new_email, user.email, user.name, link)
|
||||||
|
|
||||||
flash("You are going to receive an email to confirm email change", "success")
|
|
||||||
|
|
||||||
|
|
||||||
@dashboard_bp.route("/resend_email_change", methods=["GET", "POST"])
|
@dashboard_bp.route("/resend_email_change", methods=["GET", "POST"])
|
||||||
@login_required
|
@login_required
|
||||||
|
Loading…
Reference in New Issue
Block a user