mirror of
https://github.com/simple-login/app.git
synced 2024-09-30 05:31:30 +02:00
Schedule domain deletion instead of deleting it immediately
This commit is contained in:
parent
b4d1b3950d
commit
1c061ceb59
@ -125,8 +125,8 @@
|
|||||||
let that = $(this);
|
let that = $(this);
|
||||||
|
|
||||||
bootbox.confirm({
|
bootbox.confirm({
|
||||||
message: "All aliases associated with <b>{{ custom_domain.domain }}</b> will be also deleted, " +
|
message: "All aliases associated with <b>{{ custom_domain.domain }}</b> will be also deleted. <br>" +
|
||||||
" please confirm.",
|
"This operation is not reversible, please confirm.",
|
||||||
buttons: {
|
buttons: {
|
||||||
confirm: {
|
confirm: {
|
||||||
label: 'Yes, delete it',
|
label: 'Yes, delete it',
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from threading import Thread
|
||||||
|
|
||||||
from flask import render_template, request, redirect, url_for, flash
|
from flask import render_template, request, redirect, url_for, flash
|
||||||
from flask_login import login_required, current_user
|
from flask_login import login_required, current_user
|
||||||
|
|
||||||
@ -9,8 +11,11 @@ from app.dns_utils import (
|
|||||||
get_txt_record,
|
get_txt_record,
|
||||||
get_cname_record,
|
get_cname_record,
|
||||||
)
|
)
|
||||||
|
from app.email_utils import send_email
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
|
from app.log import LOG
|
||||||
from app.models import CustomDomain, Alias, DomainDeletedAlias
|
from app.models import CustomDomain, Alias, DomainDeletedAlias
|
||||||
|
from server import create_light_app
|
||||||
|
|
||||||
|
|
||||||
@dashboard_bp.route("/domains/<int:custom_domain_id>/dns", methods=["GET", "POST"])
|
@dashboard_bp.route("/domains/<int:custom_domain_id>/dns", methods=["GET", "POST"])
|
||||||
@ -181,9 +186,13 @@ def domain_detail(custom_domain_id):
|
|||||||
)
|
)
|
||||||
elif request.form.get("form-name") == "delete":
|
elif request.form.get("form-name") == "delete":
|
||||||
name = custom_domain.domain
|
name = custom_domain.domain
|
||||||
CustomDomain.delete(custom_domain_id)
|
LOG.d("Schedule deleting %s", custom_domain)
|
||||||
db.session.commit()
|
Thread(target=delete_domain, args=(custom_domain_id,)).start()
|
||||||
flash(f"Domain {name} has been deleted", "success")
|
flash(
|
||||||
|
f"{name} scheduled for deletion."
|
||||||
|
f"You will receive a confirmation email when the deletion is finished",
|
||||||
|
"success",
|
||||||
|
)
|
||||||
|
|
||||||
return redirect(url_for("dashboard.custom_domain"))
|
return redirect(url_for("dashboard.custom_domain"))
|
||||||
|
|
||||||
@ -192,6 +201,31 @@ def domain_detail(custom_domain_id):
|
|||||||
return render_template("dashboard/domain_detail/info.html", **locals())
|
return render_template("dashboard/domain_detail/info.html", **locals())
|
||||||
|
|
||||||
|
|
||||||
|
def delete_domain(custom_domain_id: CustomDomain):
|
||||||
|
with create_light_app().app_context():
|
||||||
|
custom_domain = CustomDomain.get(custom_domain_id)
|
||||||
|
if not custom_domain:
|
||||||
|
return
|
||||||
|
|
||||||
|
domain_name = custom_domain.domain
|
||||||
|
user = custom_domain.user
|
||||||
|
|
||||||
|
CustomDomain.delete(custom_domain.id)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
LOG.d("Domain %s deleted", domain_name)
|
||||||
|
|
||||||
|
send_email(
|
||||||
|
user.email,
|
||||||
|
f"Your domain {domain_name} has been deleted",
|
||||||
|
f"""Domain {domain_name} along with its aliases are deleted successfully.
|
||||||
|
|
||||||
|
Regards,
|
||||||
|
SimpleLogin team.
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@dashboard_bp.route("/domains/<int:custom_domain_id>/trash", methods=["GET", "POST"])
|
@dashboard_bp.route("/domains/<int:custom_domain_id>/trash", methods=["GET", "POST"])
|
||||||
@login_required
|
@login_required
|
||||||
def domain_detail_trash(custom_domain_id):
|
def domain_detail_trash(custom_domain_id):
|
||||||
|
Loading…
Reference in New Issue
Block a user