From 3d75ef974aa0bd5c592b686f0ff0cb189a5b4190 Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Tue, 24 Nov 2020 11:22:09 +0100 Subject: [PATCH] user can turn on/off pgp on mailbox that has valid pgp_finger_print --- .../templates/dashboard/mailbox_detail.html | 88 ++++++++++++------- app/dashboard/views/mailbox_detail.py | 16 +++- 2 files changed, 70 insertions(+), 34 deletions(-) diff --git a/app/dashboard/templates/dashboard/mailbox_detail.html b/app/dashboard/templates/dashboard/mailbox_detail.html index c51d91c3..1f068be1 100644 --- a/app/dashboard/templates/dashboard/mailbox_detail.html +++ b/app/dashboard/templates/dashboard/mailbox_detail.html @@ -77,44 +77,66 @@
-
-
+
+
+
Pretty Good Privacy (PGP) -
- By importing your PGP Public Key into SimpleLogin, all emails sent to {{ mailbox.email }} are - encrypted with your key.
- {% if PGP_SIGNER %} - All forwarded emails will be signed with {{ PGP_SIGNER }}. - {% endif %} -
-
- {% if not current_user.is_premium() %} - - {% endif %} - -
- - - -
- -
- - {% if mailbox.pgp_finger_print %} - + + + + +
{% endif %} - +
+ +
+ By importing your PGP Public Key into SimpleLogin, all emails sent to {{ mailbox.email }} are + encrypted with your key.
+ {% if PGP_SIGNER %} + All forwarded emails will be signed with {{ PGP_SIGNER }}. + {% endif %} +
+ + {% if not current_user.is_premium() %} + + {% endif %} + +
+ + + +
+ +
+ + + {% if mailbox.pgp_finger_print %} + + {% endif %} +
+
diff --git a/app/dashboard/views/mailbox_detail.py b/app/dashboard/views/mailbox_detail.py index 4eaa527e..eef8a0b8 100644 --- a/app/dashboard/views/mailbox_detail.py +++ b/app/dashboard/views/mailbox_detail.py @@ -146,14 +146,28 @@ def mailbox_detail_route(mailbox_id): # Free user can decide to remove their added PGP key mailbox.pgp_public_key = None mailbox.pgp_finger_print = None + mailbox.disable_pgp = False db.session.commit() flash("Your PGP public key is removed successfully", "success") return redirect( url_for("dashboard.mailbox_detail_route", mailbox_id=mailbox_id) ) + + elif request.form.get("form-name") == "toggle-pgp": + if request.form.get("pgp-enabled") == "on": + mailbox.disable_pgp = False + flash(f"PGP is enabled on {mailbox.email}", "success") + else: + mailbox.disable_pgp = True + flash(f"PGP is disabled on {mailbox.email}", "info") + + db.session.commit() + return redirect( + url_for("dashboard.mailbox_detail_route", mailbox_id=mailbox_id) + ) elif request.form.get("form-name") == "generic-subject": if request.form.get("action") == "save": - if not mailbox.pgp_finger_print: + if not mailbox.pgp_enabled(): flash( "Generic subject can only be used on PGP-enabled mailbox", "error",