From 04ecd27532d80aa440ce1984fed01b580c493f77 Mon Sep 17 00:00:00 2001 From: TuxCoder Date: Sun, 21 Jun 2020 11:52:37 +0200 Subject: [PATCH] better logging --- lenticular_cloud/views/auth.py | 11 +++++++++-- lenticular_cloud/views/frontend.py | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lenticular_cloud/views/auth.py b/lenticular_cloud/views/auth.py index 9f710b6..1d5896d 100644 --- a/lenticular_cloud/views/auth.py +++ b/lenticular_cloud/views/auth.py @@ -16,12 +16,15 @@ import http import crypt import ory_hydra_client from datetime import datetime +import logging from ..model import db, User, SecurityUser, UserSignUp from ..form.auth import ConsentForm, LoginForm, RegistrationForm from ..auth_providers import AUTH_PROVIDER_LIST +logger = logging.getLogger(__name__) + auth_views = Blueprint('auth', __name__, url_prefix='/auth') @@ -36,8 +39,12 @@ def consent(): try: consent_request = current_app.hydra_api.get_consent_request( request.args['consent_challenge']) - except ory_hydra_client.exceptions.ApiException: - return redirect(url_for('frontend.index')) + except ory_hydra_client.exceptions.ApiValueError: + logger.info(f' ory exception {e}') + #return redirect(url_for('frontend.index')) + except ory_hydra_client.exceptions.ApiException as e: + logger.fatal(f'ory exception {e}',e) + raise e requested_scope = consent_request.requested_scope requested_audiences = consent_request.requested_access_token_audience diff --git a/lenticular_cloud/views/frontend.py b/lenticular_cloud/views/frontend.py index e694bea..4538fb1 100644 --- a/lenticular_cloud/views/frontend.py +++ b/lenticular_cloud/views/frontend.py @@ -32,6 +32,7 @@ def before_request(): try: resp = current_app.oauth.session.get('/userinfo') if not current_user.is_authenticated or resp.status_code is not 200: + logger.info('user not logged in redirect') return redirect_login() except TokenExpiredError: return redirect_login()