fix case /mailbox/confirm_change is called in unauthorized user

This commit is contained in:
Son 2021-11-08 11:22:54 +01:00
parent 0e24513bcf
commit 89648a83dd
1 changed files with 2 additions and 1 deletions

View File

@ -263,7 +263,8 @@ def mailbox_confirm_change_route():
# new_email can be None if user cancels change in the meantime
if mailbox and mailbox.new_email:
if Mailbox.get_by(email=mailbox.new_email, user_id=current_user.id):
user = mailbox.user
if Mailbox.get_by(email=mailbox.new_email, user_id=user.id):
flash(f"{mailbox.new_email} is already used", "error")
return redirect(
url_for("dashboard.mailbox_detail_route", mailbox_id=mailbox.id)