mirror of
https://github.com/simple-login/app.git
synced 2024-11-16 00:48:32 +01:00
Only premium user can add PGP key
This commit is contained in:
parent
5585173583
commit
66a285e9fd
2 changed files with 26 additions and 4 deletions
|
@ -72,18 +72,33 @@
|
|||
<div class="card-title">
|
||||
Pretty Good Privacy (PGP)
|
||||
<div class="small-text">
|
||||
By importing your PGP Public Key into SimpleLogin, all emails sent to {{mailbox.email}} are <b>encrypted</b> with your key.
|
||||
By importing your PGP Public Key into SimpleLogin, all emails sent to {{ mailbox.email }} are
|
||||
<b>encrypted</b> with your key.
|
||||
</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" class="form-control" rows=10 placeholder="-----BEGIN PGP PUBLIC KEY BLOCK-----">{{mailbox.pgp_public_key or ""}}</textarea>
|
||||
<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>
|
||||
|
||||
<button class="btn btn-primary" name="action" value="save">Save</button>
|
||||
<button class="btn btn-danger float-right" name="action" value="remove">Remove</button>
|
||||
<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 %}
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -101,6 +101,12 @@ def mailbox_detail_route(mailbox_id):
|
|||
)
|
||||
elif request.form.get("form-name") == "pgp":
|
||||
if request.form.get("action") == "save":
|
||||
if not current_user.is_premium():
|
||||
flash("Only premium plan can add PGP Key", "warning")
|
||||
return redirect(
|
||||
url_for("dashboard.mailbox_detail_route", mailbox_id=mailbox_id)
|
||||
)
|
||||
|
||||
mailbox.pgp_public_key = request.form.get("pgp")
|
||||
try:
|
||||
mailbox.pgp_finger_print = load_public_key(mailbox.pgp_public_key)
|
||||
|
@ -113,6 +119,7 @@ def mailbox_detail_route(mailbox_id):
|
|||
url_for("dashboard.mailbox_detail_route", mailbox_id=mailbox_id)
|
||||
)
|
||||
elif request.form.get("action") == "remove":
|
||||
# Free user can decide to remove their added PGP key
|
||||
mailbox.pgp_public_key = None
|
||||
mailbox.pgp_finger_print = None
|
||||
db.session.commit()
|
||||
|
|
Loading…
Reference in a new issue