From 886a67e27c451934ec317e5321c8aaf5145a2001 Mon Sep 17 00:00:00 2001 From: Burathar Date: Wed, 22 Jul 2020 19:18:26 +0200 Subject: [PATCH] make it possible to get login qr code after first login, as long as password is not set. --- app/auth/routes.py | 8 ++++---- app/templates/game_player.html | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/auth/routes.py b/app/auth/routes.py index 6b86e1b..cf5ae3a 100644 --- a/app/auth/routes.py +++ b/app/auth/routes.py @@ -56,8 +56,8 @@ def generate_auth_hash(username): if user.auth_hash: flash('Auth hash is already generated') abort(403) - if user.last_login: - flash('After a player has logged in, it is no longer possible to generate a QR code.') + if user.password_hash: + flash('After a player has created a password, it is no longer possible to generate a QR code.') abort(403) user.set_auth_hash() db.session.commit() @@ -89,8 +89,8 @@ def user_qrcode(auth_hash): user = User.query.filter_by(auth_hash=auth_hash).first_or_404() if not current_user.owns_game_played_by(user): abort(403) - if user.last_login: - flash('After a player has logged in, it is no longer possible to request their QR code.') + if user.password_hash: + flash('After a player has created a password, it is no longer possible to request their QR code.') abort(403) img = generate_qr_code(url_for('auth.user_hash_login', auth_hash=auth_hash, _external=True)) return serve_pil_image(img) diff --git a/app/templates/game_player.html b/app/templates/game_player.html index eb2ec19..c14ab81 100644 --- a/app/templates/game_player.html +++ b/app/templates/game_player.html @@ -16,13 +16,13 @@ {{ wtf.quick_form(form, button_map={'submit': 'primary'}) }} - {% if player.user.auth_hash and not player.user.last_login and not player.user.password_hash %} + {% if player.user.auth_hash and not player.user.password_hash %}
qr_code_failed
- {% elif not player.user.last_login and not player.user.password_hash %} + {% elif not player.user.password_hash %}