mirror of
https://github.com/simple-login/app.git
synced 2024-09-27 20:31:30 +02:00
schedule account deletion
This commit is contained in:
parent
f3b04b9d81
commit
7946879308
@ -246,6 +246,7 @@ JOB_ONBOARDING_2 = "onboarding-2"
|
|||||||
JOB_ONBOARDING_3 = "onboarding-3"
|
JOB_ONBOARDING_3 = "onboarding-3"
|
||||||
JOB_ONBOARDING_4 = "onboarding-4"
|
JOB_ONBOARDING_4 = "onboarding-4"
|
||||||
JOB_BATCH_IMPORT = "batch-import"
|
JOB_BATCH_IMPORT = "batch-import"
|
||||||
|
JOB_DELETE_ACCOUNT = "delete-account"
|
||||||
|
|
||||||
# for pagination
|
# for pagination
|
||||||
PAGE_LIMIT = 20
|
PAGE_LIMIT = 20
|
||||||
|
@ -15,7 +15,7 @@ from wtforms import StringField, validators
|
|||||||
from wtforms.fields.html5 import EmailField
|
from wtforms.fields.html5 import EmailField
|
||||||
|
|
||||||
from app import s3, email_utils
|
from app import s3, email_utils
|
||||||
from app.config import URL, FIRST_ALIAS_DOMAIN
|
from app.config import URL, FIRST_ALIAS_DOMAIN, JOB_DELETE_ACCOUNT
|
||||||
from app.dashboard.base import dashboard_bp
|
from app.dashboard.base import dashboard_bp
|
||||||
from app.email_utils import (
|
from app.email_utils import (
|
||||||
email_can_be_used_as_mailbox,
|
email_can_be_used_as_mailbox,
|
||||||
@ -37,6 +37,7 @@ from app.models import (
|
|||||||
SLDomain,
|
SLDomain,
|
||||||
CoinbaseSubscription,
|
CoinbaseSubscription,
|
||||||
AppleSubscription,
|
AppleSubscription,
|
||||||
|
Job,
|
||||||
)
|
)
|
||||||
from app.utils import random_string, sanitize_email
|
from app.utils import random_string, sanitize_email
|
||||||
|
|
||||||
@ -178,12 +179,21 @@ def setting():
|
|||||||
return redirect(url_for("dashboard.setting"))
|
return redirect(url_for("dashboard.setting"))
|
||||||
|
|
||||||
elif request.form.get("form-name") == "delete-account":
|
elif request.form.get("form-name") == "delete-account":
|
||||||
LOG.warning("Delete account %s", current_user)
|
# Schedule delete account job
|
||||||
User.delete(current_user.id)
|
LOG.warning("schedule delete account job for %s", current_user)
|
||||||
db.session.commit()
|
Job.create(
|
||||||
flash("Your account has been deleted", "success")
|
name=JOB_DELETE_ACCOUNT,
|
||||||
logout_user()
|
payload={"user_id": current_user.id},
|
||||||
return redirect(url_for("auth.register"))
|
run_at=arrow.now(),
|
||||||
|
commit=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
flash(
|
||||||
|
"Your account deletion has been scheduled. "
|
||||||
|
"You'll receive an email when the deletion is finished",
|
||||||
|
"success",
|
||||||
|
)
|
||||||
|
return redirect(url_for("dashboard.setting"))
|
||||||
|
|
||||||
elif request.form.get("form-name") == "change-alias-generator":
|
elif request.form.get("form-name") == "change-alias-generator":
|
||||||
scheme = int(request.form.get("alias-generator-scheme"))
|
scheme = int(request.form.get("alias-generator-scheme"))
|
||||||
|
@ -11,6 +11,7 @@ from app.config import (
|
|||||||
JOB_ONBOARDING_2,
|
JOB_ONBOARDING_2,
|
||||||
JOB_ONBOARDING_4,
|
JOB_ONBOARDING_4,
|
||||||
JOB_BATCH_IMPORT,
|
JOB_BATCH_IMPORT,
|
||||||
|
JOB_DELETE_ACCOUNT,
|
||||||
)
|
)
|
||||||
from app.email_utils import (
|
from app.email_utils import (
|
||||||
send_email,
|
send_email,
|
||||||
@ -149,7 +150,25 @@ if __name__ == "__main__":
|
|||||||
batch_import_id = job.payload.get("batch_import_id")
|
batch_import_id = job.payload.get("batch_import_id")
|
||||||
batch_import = BatchImport.get(batch_import_id)
|
batch_import = BatchImport.get(batch_import_id)
|
||||||
handle_batch_import(batch_import)
|
handle_batch_import(batch_import)
|
||||||
|
elif job.name == JOB_DELETE_ACCOUNT:
|
||||||
|
user_id = job.payload.get("user_id")
|
||||||
|
user = User.get(user_id)
|
||||||
|
|
||||||
|
if not user:
|
||||||
|
LOG.exception("No user found for %s", user_id)
|
||||||
|
continue
|
||||||
|
|
||||||
|
user_email = user.email
|
||||||
|
LOG.warning("Delete user %s", user)
|
||||||
|
User.delete(user.id)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
send_email(
|
||||||
|
user_email,
|
||||||
|
"Your SimpleLogin account has been deleted",
|
||||||
|
render("transactional/account-delete.txt"),
|
||||||
|
render("transactional/account-delete.html"),
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
LOG.exception("Unknown job name %s", job.name)
|
LOG.exception("Unknown job name %s", job.name)
|
||||||
|
|
||||||
|
15
templates/emails/transactional/account-delete.html
Normal file
15
templates/emails/transactional/account-delete.html
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% call text() %}
|
||||||
|
<h1>
|
||||||
|
Your SimpleLogin account has been deleted successfully.
|
||||||
|
</h1>
|
||||||
|
{% endcall %}
|
||||||
|
|
||||||
|
{% call text() %}
|
||||||
|
Thank you for having used SimpleLogin.
|
||||||
|
{% endcall %}
|
||||||
|
|
||||||
|
{{ render_text('Best, <br />SimpleLogin Team.') }}
|
||||||
|
{% endblock %}
|
6
templates/emails/transactional/account-delete.txt
Normal file
6
templates/emails/transactional/account-delete.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
Your SimpleLogin account has been deleted successfully.
|
||||||
|
|
||||||
|
Thank you for having used SimpleLogin.
|
||||||
|
|
||||||
|
Best,
|
||||||
|
SimpleLogin team.
|
Loading…
Reference in New Issue
Block a user