Open PGP to everyone

This commit is contained in:
Son NK 2020-03-17 09:22:29 +01:00
parent 8faf34ce40
commit ea43b8f685
6 changed files with 39 additions and 17 deletions

View file

@ -1,5 +1,5 @@
repos: repos:
- repo: https://github.com/ambv/black - repo: https://github.com/psf/black
rev: stable rev: stable
hooks: hooks:
- id: black - id: black

View file

@ -64,8 +64,6 @@
<!-- END Change email --> <!-- END Change email -->
<!-- Change PGP Public key -->
{% if current_user.can_use_pgp %}
<div class="card"> <div class="card">
<form method="post"> <form method="post">
<input type="hidden" name="form-name" value="pgp"> <input type="hidden" name="form-name" value="pgp">
@ -91,8 +89,6 @@
</form> </form>
</div> </div>
{% endif %}
<!-- END PGP Public key -->
</div> </div>
{% endblock %} {% endblock %}

View file

@ -100,12 +100,6 @@ def mailbox_detail_route(mailbox_id):
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") == "pgp": 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": if request.form.get("action") == "save":
mailbox.pgp_public_key = request.form.get("pgp") mailbox.pgp_public_key = request.form.get("pgp")
try: try:

View file

@ -143,11 +143,6 @@ class User(db.Model, ModelMixin, UserMixin):
db.ForeignKey("mailbox.id"), nullable=True, default=None db.ForeignKey("mailbox.id"), nullable=True, default=None
) )
# feature flag
can_use_pgp = db.Column(
db.Boolean, default=False, nullable=False, server_default="0"
)
profile_picture = db.relationship(File) profile_picture = db.relationship(File)
@classmethod @classmethod

View file

@ -0,0 +1,38 @@
"""empty message
Revision ID: 91b69dfad2f1
Revises: 9081f1a90939
Create Date: 2020-03-16 21:15:48.652860
"""
import sqlalchemy_utils
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "91b69dfad2f1"
down_revision = "9081f1a90939"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("users", "can_use_pgp")
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"users",
sa.Column(
"can_use_pgp",
sa.BOOLEAN(),
server_default=sa.text("false"),
autoincrement=False,
nullable=False,
),
)
# ### end Alembic commands ###

View file

@ -131,7 +131,6 @@ def fake_data():
activated=True, activated=True,
is_admin=True, is_admin=True,
otp_secret="base32secret3232", otp_secret="base32secret3232",
can_use_pgp=True,
) )
db.session.commit() db.session.commit()