add User.can_use_fido

This commit is contained in:
Son NK 2020-05-07 17:56:25 +02:00
parent 84c529c867
commit 18d62a81d1
2 changed files with 7 additions and 2 deletions

View File

@ -31,7 +31,7 @@ def fido():
user = User.get(user_id)
if not (user and (user.fido_enabled())):
if not (user and user.fido_enabled()):
flash("Only user with security key linked should go to this page", "warning")
return redirect(url_for("auth.login"))

View File

@ -140,8 +140,13 @@ class User(db.Model, ModelMixin, UserMixin):
fido_pk = db.Column(db.String(), nullable=True, unique=True)
fido_sign_count = db.Column(db.Integer(), nullable=True)
# whether user can use Fido
can_use_fido = db.Column(
db.Boolean, default=False, nullable=False, server_default="0"
)
def fido_enabled(self) -> bool:
if self.fido_uuid is not None:
if self.can_use_fido and self.fido_uuid is not None:
return True
return False