set mailbox.pgp_finger_print when adding PGP key
This commit is contained in:
parent
2eef010bad
commit
486df7fefc
|
@ -14,6 +14,7 @@ from app.extensions import db
|
||||||
from app.log import LOG
|
from app.log import LOG
|
||||||
from app.models import GenEmail, DeletedAlias
|
from app.models import GenEmail, DeletedAlias
|
||||||
from app.models import Mailbox
|
from app.models import Mailbox
|
||||||
|
from app.pgp_utils import PGPException, load_public_key
|
||||||
|
|
||||||
|
|
||||||
class ChangeEmailForm(FlaskForm):
|
class ChangeEmailForm(FlaskForm):
|
||||||
|
@ -96,13 +97,16 @@ def mailbox_detail_route(mailbox_id):
|
||||||
elif request.form.get("form-name") == "pgp":
|
elif request.form.get("form-name") == "pgp":
|
||||||
if request.form.get("action") == "save":
|
if request.form.get("action") == "save":
|
||||||
mailbox.pgp_public_key = request.form.get("pgp")
|
mailbox.pgp_public_key = request.form.get("pgp")
|
||||||
# TODO
|
try:
|
||||||
# mailbox.pgp_finger_print = load_public_key(mailbox.pgp_public_key)
|
mailbox.pgp_finger_print = load_public_key(mailbox.pgp_public_key)
|
||||||
db.session.commit()
|
except PGPException:
|
||||||
flash("Your PGP public key is saved successfully", "success")
|
flash("Cannot add the public key, please verify it", "error")
|
||||||
return redirect(
|
else:
|
||||||
url_for("dashboard.mailbox_detail_route", mailbox_id=mailbox_id)
|
db.session.commit()
|
||||||
)
|
flash("Your PGP public key is saved successfully", "success")
|
||||||
|
return redirect(
|
||||||
|
url_for("dashboard.mailbox_detail_route", mailbox_id=mailbox_id)
|
||||||
|
)
|
||||||
elif request.form.get("action") == "remove":
|
elif request.form.get("action") == "remove":
|
||||||
mailbox.pgp_public_key = None
|
mailbox.pgp_public_key = None
|
||||||
mailbox.pgp_finger_print = None
|
mailbox.pgp_finger_print = None
|
||||||
|
|
Loading…
Reference in a new issue