handle case mailbox new address is already used
This commit is contained in:
parent
19088ba85f
commit
18acfd9a42
|
@ -263,6 +263,12 @@ def mailbox_confirm_change_route():
|
||||||
|
|
||||||
# new_email can be None if user cancels change in the meantime
|
# new_email can be None if user cancels change in the meantime
|
||||||
if mailbox and mailbox.new_email:
|
if mailbox and mailbox.new_email:
|
||||||
|
if Mailbox.get_by(email=mailbox.new_email):
|
||||||
|
flash(f"{mailbox.new_email} is already used", "error")
|
||||||
|
return redirect(
|
||||||
|
url_for("dashboard.mailbox_detail_route", mailbox_id=mailbox.id)
|
||||||
|
)
|
||||||
|
|
||||||
mailbox.email = mailbox.new_email
|
mailbox.email = mailbox.new_email
|
||||||
mailbox.new_email = None
|
mailbox.new_email = None
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue