From 71919a4ce9c78ed7d341367df8e8a169c11e7d23 Mon Sep 17 00:00:00 2001 From: Dave Page Date: Mon, 17 Jun 2019 14:12:36 +0100 Subject: [PATCH] Prevent the "Please login to access this page" message displaying multiple times. Fixes #4306 --- docs/en_US/release_notes_4_9.rst | 1 + web/pgadmin/__init__.py | 7 +++++-- web/pgadmin/browser/templates/browser/index.html | 5 ++++- web/pgadmin/templates/base.html | 1 - web/pgadmin/utils/session.py | 5 ++++- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/docs/en_US/release_notes_4_9.rst b/docs/en_US/release_notes_4_9.rst index 2e06448d9..30d910bbc 100644 --- a/docs/en_US/release_notes_4_9.rst +++ b/docs/en_US/release_notes_4_9.rst @@ -23,6 +23,7 @@ Bug fixes | `Bug #4288 `_ - Initial support for PostgreSQL 12. | `Bug #4290 `_ - Initial support for PostgreSQL 12. | `Bug #4255 `_ - Prevent the geometry viewer grabbing key presses when not in focus under Firefox, IE and Edge. +| `Bug #4306 `_ - Prevent the "Please login to access this page" message displaying multiple times. | `Bug #4310 `_ - Ensure that the Return key can be used to submit the Master Password dialogue. | `Bug #4317 `_ - Ensure that browser auto-fill doesn't cause Help pages to be opened unexpectedly. | `Bug #4320 `_ - Fix issue where SSH tunnel connection using password is failing, it's regression of Master Password. diff --git a/web/pgadmin/__init__.py b/web/pgadmin/__init__.py index 9cb55cfc3..baf0ca307 100644 --- a/web/pgadmin/__init__.py +++ b/web/pgadmin/__init__.py @@ -646,8 +646,11 @@ def create_app(app_name=None): # if the server is restarted the in memory key will be lost # but the user session may still be active. Logout the user # to get the key again when login - if config.SERVER_MODE and current_app.keyManager.get() is None: - logout_user() + if config.SERVER_MODE and current_user.is_authenticated: + if current_app.keyManager.get() is None and \ + request.endpoint not in ('security.login', + 'security.logout'): + logout_user() @app.after_request def after_request(response): diff --git a/web/pgadmin/browser/templates/browser/index.html b/web/pgadmin/browser/templates/browser/index.html index 0a785d6ba..8b3866c23 100644 --- a/web/pgadmin/browser/templates/browser/index.html +++ b/web/pgadmin/browser/templates/browser/index.html @@ -78,7 +78,6 @@ require.onResourceLoad = function (context, map, depMaps) { window.onload = function(e){ setTimeout(function() { var gravatarImg = {{ IMG.PREPARE_HTML()|safe }} - //$('#navbar-menu .navbar-right > li > a').html(gravatarImg); var navbarUser = document.getElementById("navbar-user"); if (navbarUser) { navbarUser.innerHTML = gravatarImg; @@ -88,6 +87,10 @@ window.onload = function(e){ {% endif %} {% endblock %} +{% block css_link %} + +{% endblock %} + {% block body %}
diff --git a/web/pgadmin/templates/base.html b/web/pgadmin/templates/base.html index 7a53c3111..8a7b255b5 100644 --- a/web/pgadmin/templates/base.html +++ b/web/pgadmin/templates/base.html @@ -20,7 +20,6 @@ - diff --git a/web/pgadmin/utils/session.py b/web/pgadmin/utils/session.py index 7c0b6af28..18d16121c 100644 --- a/web/pgadmin/utils/session.py +++ b/web/pgadmin/utils/session.py @@ -364,7 +364,10 @@ def pga_unauthorised(): info='PGADMIN_LOGIN_REQUIRED' ) - if login_message: + # flash messages are only required if the request was from a + # security page, otherwise it will be redirected to login page + # anyway + if login_message and 'security' in request.endpoint: flash(login_message, category=lm.login_message_category) return redirect(login_url(lm.login_view, request.url))