user can turn on/off pgp on mailbox that has valid pgp_finger_print
This commit is contained in:
parent
cbbb472d06
commit
3d75ef974a
|
@ -77,44 +77,66 @@
|
||||||
|
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="card-title">
|
<div class="card-title">
|
||||||
|
<div class="d-flex">
|
||||||
Pretty Good Privacy (PGP)
|
Pretty Good Privacy (PGP)
|
||||||
<div class="small-text mt-1">
|
|
||||||
By importing your PGP Public Key into SimpleLogin, all emails sent to {{ mailbox.email }} are
|
|
||||||
<b>encrypted</b> with your key. <br>
|
|
||||||
{% if PGP_SIGNER %}
|
|
||||||
All forwarded emails will be signed with <b>{{ PGP_SIGNER }}</b>.
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if not current_user.is_premium() %}
|
|
||||||
<div class="alert alert-danger" role="alert">
|
|
||||||
This feature is only available in premium plan.
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label">PGP Public Key</label>
|
|
||||||
|
|
||||||
<textarea name="pgp"
|
|
||||||
{% if not current_user.is_premium() %} disabled {% endif %}
|
|
||||||
class="form-control" rows=10
|
|
||||||
placeholder="-----BEGIN PGP PUBLIC KEY BLOCK-----">{{ mailbox.pgp_public_key or "" }}</textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form method="post">
|
|
||||||
<input type="hidden" name="form-name" value="pgp">
|
|
||||||
<button class="btn btn-primary" name="action"
|
|
||||||
{% if not current_user.is_premium() %} disabled {% endif %}
|
|
||||||
value="save">Save
|
|
||||||
</button>
|
|
||||||
{% if mailbox.pgp_finger_print %}
|
{% if mailbox.pgp_finger_print %}
|
||||||
<button class="btn btn-danger float-right" name="action" value="remove">Remove</button>
|
<form method="post">
|
||||||
|
<input type="hidden" name="form-name" value="toggle-pgp">
|
||||||
|
|
||||||
|
<label class="custom-switch cursor" style="padding-left: 1rem"
|
||||||
|
data-toggle="tooltip"
|
||||||
|
{% if mailbox.disable_pgp %}
|
||||||
|
title="Enable PGP"
|
||||||
|
{% else %}
|
||||||
|
title="Disable PGP"
|
||||||
|
{% endif %}
|
||||||
|
>
|
||||||
|
<input type="checkbox" class="custom-switch-input" name="pgp-enabled"
|
||||||
|
{{ "" if mailbox.disable_pgp else "checked" }}>
|
||||||
|
<span class="custom-switch-indicator"></span>
|
||||||
|
</label>
|
||||||
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</form>
|
</div>
|
||||||
|
|
||||||
|
<div class="small-text mt-1">
|
||||||
|
By importing your PGP Public Key into SimpleLogin, all emails sent to {{ mailbox.email }} are
|
||||||
|
<b>encrypted</b> with your key. <br>
|
||||||
|
{% if PGP_SIGNER %}
|
||||||
|
All forwarded emails will be signed with <b>{{ PGP_SIGNER }}</b>.
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if not current_user.is_premium() %}
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
This feature is only available in premium plan.
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">PGP Public Key</label>
|
||||||
|
|
||||||
|
<textarea name="pgp"
|
||||||
|
{% if not current_user.is_premium() %} disabled {% endif %}
|
||||||
|
class="form-control" rows=10
|
||||||
|
placeholder="-----BEGIN PGP PUBLIC KEY BLOCK-----">{{ mailbox.pgp_public_key or "" }}</textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form method="post">
|
||||||
|
<input type="hidden" name="form-name" value="pgp">
|
||||||
|
<button class="btn btn-primary" name="action"
|
||||||
|
{% if not current_user.is_premium() %} disabled {% endif %}
|
||||||
|
value="save">Save
|
||||||
|
</button>
|
||||||
|
{% if mailbox.pgp_finger_print %}
|
||||||
|
<button class="btn btn-danger float-right" name="action" value="remove">Remove</button>
|
||||||
|
{% endif %}
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card" {% if not mailbox.pgp_enabled() %} disabled {% endif %}>
|
<div class="card" {% if not mailbox.pgp_enabled() %} disabled {% endif %}>
|
||||||
|
|
|
@ -146,14 +146,28 @@ def mailbox_detail_route(mailbox_id):
|
||||||
# Free user can decide to remove their added PGP key
|
# Free user can decide to remove their added PGP key
|
||||||
mailbox.pgp_public_key = None
|
mailbox.pgp_public_key = None
|
||||||
mailbox.pgp_finger_print = None
|
mailbox.pgp_finger_print = None
|
||||||
|
mailbox.disable_pgp = False
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash("Your PGP public key is removed successfully", "success")
|
flash("Your PGP public key is removed successfully", "success")
|
||||||
return redirect(
|
return redirect(
|
||||||
url_for("dashboard.mailbox_detail_route", mailbox_id=mailbox_id)
|
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":
|
elif request.form.get("form-name") == "generic-subject":
|
||||||
if request.form.get("action") == "save":
|
if request.form.get("action") == "save":
|
||||||
if not mailbox.pgp_finger_print:
|
if not mailbox.pgp_enabled():
|
||||||
flash(
|
flash(
|
||||||
"Generic subject can only be used on PGP-enabled mailbox",
|
"Generic subject can only be used on PGP-enabled mailbox",
|
||||||
"error",
|
"error",
|
||||||
|
|
Loading…
Reference in a new issue