diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 637d2fdb..9e2e02c3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -154,7 +154,7 @@ Here are the small sum-ups of the directory structures and their roles: The code is formatted using https://github.com/psf/black, to format the code, simply run ``` -poetry run black . +poetry run ruff format . ``` The code is also checked with `flake8`, make sure to run `flake8` before creating the pull request by diff --git a/app/dashboard/__init__.py b/app/dashboard/__init__.py index 50fdbb79..d3cb1615 100644 --- a/app/dashboard/__init__.py +++ b/app/dashboard/__init__.py @@ -33,6 +33,7 @@ from .views import ( notification, support, account_setting, + import_export, ) __all__ = [ @@ -70,4 +71,5 @@ __all__ = [ "notification", "support", "account_setting", + "import_export", ] diff --git a/app/dashboard/views/account_setting.py b/app/dashboard/views/account_setting.py index 5e3e0583..29f538a2 100644 --- a/app/dashboard/views/account_setting.py +++ b/app/dashboard/views/account_setting.py @@ -24,7 +24,6 @@ from app.email_utils import ( personal_email_already_used, ) from app.extensions import limiter -from app.jobs.export_user_data_job import ExportUserDataJob from app.log import LOG from app.models import ( BlockBehaviourEnum, @@ -127,14 +126,6 @@ def account_setting(): ) send_reset_password_email(current_user) return redirect(url_for("dashboard.account_setting")) - elif request.form.get("form-name") == "send-full-user-report": - if ExportUserDataJob(current_user).store_job_in_db(): - flash( - "You will receive your SimpleLogin data via email shortly", - "success", - ) - else: - flash("An export of your data is currently in progress", "error") partner_sub = None partner_name = None diff --git a/app/dashboard/views/import_export.py b/app/dashboard/views/import_export.py new file mode 100644 index 00000000..e89da806 --- /dev/null +++ b/app/dashboard/views/import_export.py @@ -0,0 +1,42 @@ +from flask import ( + render_template, + request, + redirect, + url_for, + flash, +) +from flask_login import login_required, current_user + +from app.dashboard.base import dashboard_bp +from app.dashboard.views.enter_sudo import sudo_required +from app.extensions import limiter +from app.jobs.export_user_data_job import ExportUserDataJob +from app.utils import ( + CSRFValidationForm, +) + + +@dashboard_bp.route("/import_export", methods=["GET", "POST"]) +@login_required +@sudo_required +@limiter.limit("5/minute", methods=["POST"]) +def import_export(): + csrf_form = CSRFValidationForm() + + if request.method == "POST": + if not csrf_form.validate(): + flash("Invalid request", "warning") + return redirect(url_for("dashboard.setting")) + if request.form.get("form-name") == "send-full-user-report": + if ExportUserDataJob(current_user).store_job_in_db(): + flash( + "You will receive your SimpleLogin data via email shortly", + "success", + ) + else: + flash("An export of your data is currently in progress", "error") + + return render_template( + "dashboard/import_export.html", + csrf_form=csrf_form, + ) diff --git a/templates/dashboard/account_setting.html b/templates/dashboard/account_setting.html index a6ba0b51..f4d8eaa2 100644 --- a/templates/dashboard/account_setting.html +++ b/templates/dashboard/account_setting.html @@ -1,7 +1,7 @@ {% extends "default.html" %} {% set active_page = "setting" %} -{% block title %}Settings{% endblock %} +{% block title %}Account Settings{% endblock %} {% block head %} +{% endblock %} +{% block default_content %} + +
+ +
+
+
Alias import/export
+
+ You can import your aliases created on other platforms into SimpleLogin. + You can also export your aliases to a readable csv format for a future batch import. +
+ Batch Import + Export Aliases +
+
+ + +
+
+
SimpleLogin data export
+
+ As per GDPR (General Data Protection Regulation) law, you can request a copy of your data which are stored on + SimpleLogin. + A zip file that contains all information will be sent to your SimpleLogin account address. +
+
+
+
+ {{ csrf_form.csrf_token }} + + +
+
+
+
+
+ +
+{% endblock %} +{% block script %} + + +{% endblock %} diff --git a/templates/header.html b/templates/header.html index 4920c896..9274cb44 100644 --- a/templates/header.html +++ b/templates/header.html @@ -152,6 +152,10 @@ href="{{ url_for('dashboard.account_setting') }}"> Account settings + + Import/export + Sign out