Informative error should be shown if Oauth2 profile does not have email id registered. Fixes #6590

pull/55/head
Khushboo Vashi 2021-07-07 17:58:49 +05:30 committed by Akshay Joshi
parent 36086722b3
commit 5ee8045916
1 changed files with 6 additions and 4 deletions

View File

@ -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: