From 5ee8045916c7affffbcc2ea204b315d116e40c1d Mon Sep 17 00:00:00 2001 From: Khushboo Vashi Date: Wed, 7 Jul 2021 17:58:49 +0530 Subject: [PATCH] Informative error should be shown if Oauth2 profile does not have email id registered. Fixes #6590 --- web/pgadmin/authenticate/oauth2.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/web/pgadmin/authenticate/oauth2.py b/web/pgadmin/authenticate/oauth2.py index 67c00ba71..9a6e666ad 100644 --- a/web/pgadmin/authenticate/oauth2.py +++ b/web/pgadmin/authenticate/oauth2.py @@ -58,8 +58,9 @@ def init_app(app): session['auth_source_manager'] = auth_obj.as_dict() session['auth_obj'] = None return redirect(get_post_login_redirect()) + session['auth_obj'] = None logout_user() - flash(msg) + flash(msg, 'danger') return redirect(get_post_login_redirect()) @blueprint.route('/logout', endpoint="logout", @@ -115,13 +116,14 @@ class OAuth2Authentication(BaseAuthentication): def login(self, form): profile = self.get_user_profile() - print(profile) if 'email' not in profile or not profile['email']: current_app.logger.exception( - 'An email is required for authentication' + "An email id is required to login into pgAdmin. " + "Please update your Oauth2 profile." ) return False, gettext( - "An email is required for the oauth authentication.") + "An email id is required to login into pgAdmin. " + "Please update your Oauth2 profile.") user, msg = self.__auto_create_user(profile) if user: