From 335a6aa774c3fb22482528c1452c58d6daef533f Mon Sep 17 00:00:00 2001 From: Jacobe2169 Date: Wed, 14 Feb 2024 14:47:10 +0100 Subject: [PATCH] debug public login --- src/pypnusershub/routes.py | 11 +++++------ src/pypnusershub/utils.py | 12 ++++-------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/pypnusershub/routes.py b/src/pypnusershub/routes.py index 128c554..6f31ae1 100755 --- a/src/pypnusershub/routes.py +++ b/src/pypnusershub/routes.py @@ -142,15 +142,14 @@ def login(): def public_login(): if not current_app.config.get("PUBLIC_ACCESS_USERNAME", {}): raise Forbidden + login = current_app.config.get("PUBLIC_ACCESS_USERNAME") user = db.session.execute( - sa.select(models.AppUser) - .where( - models.AppUser.identifiant - == current_app.config.get("PUBLIC_ACCESS_USERNAME") - ) - .filter(models.AppUser.id_application == get_current_app_id()) + sa.select(models.User) + .where(models.User.identifiant == login) + .where(models.User.filter_by_app(code_app="GN")) ).scalar_one() + user_dict = user.as_dict() login_user(user) # Génération d'un token diff --git a/src/pypnusershub/utils.py b/src/pypnusershub/utils.py index d9a3318..f5dc0bc 100644 --- a/src/pypnusershub/utils.py +++ b/src/pypnusershub/utils.py @@ -81,15 +81,11 @@ def get_current_app_id(): elif "CODE_APPLICATION" in current_app.config: from pypnusershub.db.models import Application - return ( - db.session.execute( - select(Application).filter_by( - code_application=current_app.config["CODE_APPLICATION"], - ) + return db.session.execute( + select(Application.id_application).filter_by( + code_application=current_app.config["CODE_APPLICATION"], ) - .scalar_one() - .id_application - ) + ).scalar_one() else: return None