public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin][RM4306] Please log in to access the page Message displayed unnecessarily
2+ messages / 2 participants
[nested] [flat]

* [pgAdmin][RM4306] Please log in to access the page Message displayed unnecessarily
@ 2019-06-17 11:32  Aditya Toshniwal <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Aditya Toshniwal @ 2019-06-17 11:32 UTC (permalink / raw)
  To: pgadmin-hackers

Hi Hackers,

Attached patch will suppress unnecessary "Please log in to access the page"
flash messages on the login page.

Kindly review.

-- 
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB India | Pune
"Don't Complain about Heat, Plant a TREE"


Attachments:

  [application/octet-stream] RM4306.patch (3.1K, 3-RM4306.patch)
  download | inline diff:
diff --git a/web/pgadmin/__init__.py b/web/pgadmin/__init__.py
index 9cb55cfc..baf0ca30 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 0a785d6b..8b3866c2 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 %}
+<link type="text/css" rel="stylesheet" href="{{ url_for('browser.browser_css')}}"/>
+{% endblock %}
+
 {% block body %}
 <div id="pg-spinner" class="pg-sp-container">
   <div class="pg-sp-content">
diff --git a/web/pgadmin/templates/base.html b/web/pgadmin/templates/base.html
index 7a53c311..8a7b255b 100644
--- a/web/pgadmin/templates/base.html
+++ b/web/pgadmin/templates/base.html
@@ -20,7 +20,6 @@
 
     <!-- Base template stylesheets -->
     <link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='vendor/backgrid/backgrid.css')}}"/>
-    <link type="text/css" rel="stylesheet" href="{{ url_for('browser.browser_css')}}"/>
     <link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='js/generated/style.css')}}"/>
     <link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='js/generated/pgadmin.css')}}"/>
     <link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/alertify.noanimation.css')}}" id="alertify-no-animation"/>
diff --git a/web/pgadmin/utils/session.py b/web/pgadmin/utils/session.py
index 7c0b6af2..18d16121 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))


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [pgAdmin][RM4306] Please log in to access the page Message displayed unnecessarily
@ 2019-06-17 13:13  Dave Page <[email protected]>
  parent: Aditya Toshniwal <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Dave Page @ 2019-06-17 13:13 UTC (permalink / raw)
  To: Aditya Toshniwal <[email protected]>; +Cc: pgadmin-hackers

Thanks, patch applied.

On Mon, Jun 17, 2019 at 12:33 PM Aditya Toshniwal <
[email protected]> wrote:

> Hi Hackers,
>
> Attached patch will suppress unnecessary "Please log in to access the
> page" flash messages on the login page.
>
> Kindly review.
>
> --
> Thanks and Regards,
> Aditya Toshniwal
> Software Engineer | EnterpriseDB India | Pune
> "Don't Complain about Heat, Plant a TREE"
>


-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2019-06-17 13:13 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-06-17 11:32 [pgAdmin][RM4306] Please log in to access the page Message displayed unnecessarily Aditya Toshniwal <[email protected]>
2019-06-17 13:13 ` Dave Page <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox