Only user with can_use_pgp on can use GPG

This commit is contained in:
Son NK 2020-03-08 23:12:35 +01:00
parent afc5b6fe1a
commit 911c38710e
2 changed files with 8 additions and 0 deletions

View File

@ -57,6 +57,7 @@
<!-- Change PGP Public key -->
{% if current_user.can_use_pgp %}
<div class="card">
<form method="post">
<input type="hidden" name="form-name" value="pgp">
@ -82,6 +83,7 @@
</form>
</div>
{% endif %}
<!-- END PGP Public key -->
</div>

View File

@ -95,6 +95,12 @@ def mailbox_detail_route(mailbox_id):
url_for("dashboard.mailbox_detail_route", mailbox_id=mailbox_id)
)
elif request.form.get("form-name") == "pgp":
if not current_user.can_use_pgp:
flash("You cannot use PGP", "error")
return redirect(
url_for("dashboard.mailbox_detail_route", mailbox_id=mailbox_id)
)
if request.form.get("action") == "save":
mailbox.pgp_public_key = request.form.get("pgp")
try: