mirror of
https://github.com/simple-login/app.git
synced 2024-11-13 07:31:12 +01:00
after deleting an alias, user should stay on the same page (#1546)
* after deleting an alias, user should stay on the same page * Fix delete alias mlec (#1547) * Specify how to create the certificates if they don't exist in readme (#1533) * Remove id= from get 🩹 * Add flash message level 🩹 * Rename transfer_mailbox back to new_mailbox in the create-mailbox part 🩹 Co-authored-by: rubencm <rubencm@gmail.com> * Fix delete alias mlec (#1552) * Specify how to create the certificates if they don't exist in readme (#1533) * Remove id= from get 🩹 * Add flash message level 🩹 * Rename transfer_mailbox back to new_mailbox in the create-mailbox part 🩹 * Linting files to pass test 🎨 Co-authored-by: rubencm <rubencm@gmail.com> Co-authored-by: mlec <42201667+mlec1@users.noreply.github.com> Co-authored-by: rubencm <rubencm@gmail.com>
This commit is contained in:
parent
51916a8c8a
commit
170082e2c1
3 changed files with 17 additions and 8 deletions
|
@ -86,7 +86,7 @@ def delete_mailbox(mailbox_id):
|
|||
|
||||
"""
|
||||
user = g.user
|
||||
mailbox = Mailbox.get(id=mailbox_id)
|
||||
mailbox = Mailbox.get(mailbox_id)
|
||||
|
||||
if not mailbox or mailbox.user_id != user.id:
|
||||
return jsonify(error="Forbidden"), 403
|
||||
|
|
|
@ -150,7 +150,13 @@ def index():
|
|||
flash(f"Alias {alias.email} has been disabled", "success")
|
||||
|
||||
return redirect(
|
||||
url_for("dashboard.index", query=query, sort=sort, filter=alias_filter)
|
||||
url_for(
|
||||
"dashboard.index",
|
||||
query=query,
|
||||
sort=sort,
|
||||
filter=alias_filter,
|
||||
page=page,
|
||||
)
|
||||
)
|
||||
|
||||
mailboxes = current_user.mailboxes()
|
||||
|
|
|
@ -69,17 +69,20 @@ def mailbox_route():
|
|||
transfer_mailbox = Mailbox.get(transfer_mailbox_id)
|
||||
|
||||
if not transfer_mailbox or transfer_mailbox.user_id != current_user.id:
|
||||
flash("You must transfer the aliases to a mailbox you own.")
|
||||
flash(
|
||||
"You must transfer the aliases to a mailbox you own.", "error"
|
||||
)
|
||||
return redirect(url_for("dashboard.mailbox_route"))
|
||||
|
||||
if transfer_mailbox.id == mailbox.id:
|
||||
flash(
|
||||
"You can not transfer the aliases to the mailbox you want to delete."
|
||||
"You can not transfer the aliases to the mailbox you want to delete.",
|
||||
"error",
|
||||
)
|
||||
return redirect(url_for("dashboard.mailbox_route"))
|
||||
|
||||
if not transfer_mailbox.verified:
|
||||
flash("Your new mailbox is not verified")
|
||||
flash("Your new mailbox is not verified", "error")
|
||||
return redirect(url_for("dashboard.mailbox_route"))
|
||||
|
||||
# Schedule delete account job
|
||||
|
@ -147,12 +150,12 @@ def mailbox_route():
|
|||
elif not email_can_be_used_as_mailbox(mailbox_email):
|
||||
flash(f"You cannot use {mailbox_email}.", "error")
|
||||
else:
|
||||
transfer_mailbox = Mailbox.create(
|
||||
new_mailbox = Mailbox.create(
|
||||
email=mailbox_email, user_id=current_user.id
|
||||
)
|
||||
Session.commit()
|
||||
|
||||
send_verification_email(current_user, transfer_mailbox)
|
||||
send_verification_email(current_user, new_mailbox)
|
||||
|
||||
flash(
|
||||
f"You are going to receive an email to confirm {mailbox_email}.",
|
||||
|
@ -162,7 +165,7 @@ def mailbox_route():
|
|||
return redirect(
|
||||
url_for(
|
||||
"dashboard.mailbox_detail_route",
|
||||
mailbox_id=transfer_mailbox.id,
|
||||
mailbox_id=new_mailbox.id,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue