[Lada-commits] [PATCH 2 of 2] Improve error handling on authentication loss

Wald Commits scm-commit at wald.intevation.org
Fri Mar 13 17:17:14 CET 2015


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1426263429 -3600
# Branch openid
# Node ID fb89f61ab2727fab03266b69a8cf58204715122b
# Parent  ab48824713e2d1eba83b57d0d4b45bc934645d48
Improve error handling on authentication loss.

diff -r ab48824713e2 -r fb89f61ab272 app/override/RestProxy.js
--- a/app/override/RestProxy.js	Fri Mar 13 15:00:55 2015 +0100
+++ b/app/override/RestProxy.js	Fri Mar 13 17:17:09 2015 +0100
@@ -15,20 +15,31 @@
     },
 
     processResponse: function (success, operation, request, response, callback, scope) {
-        if (!success && response.status == 401) {
+        /* Check if we were authenticated at one point (Lada.openIDParams) and
+         * if the response means that we lost that authentcation */
+        if (Lada.openIDParams && !success && response.status == 401) {
             var json = Ext.decode(response.responseText);
             if (json) {
-                if (json.message == "699") {
+                if (json.message === "699" || json.message === "698") {
                     /* This is the unauthorized message with the authentication
                      * redirect in the data */
 
                     /* We decided to handle this with a redirect to the identity
                      * provider. In which case we have no other option then to
                      * handle it here with relaunch. */
-                    Lada.launch(); // Data loss!
+                    Ext.MessageBox.confirm('Erneutes Login erforderlich',
+                        'Der Server konnte die Anfrage nicht authentifizieren.<br/>'+
+                        'Für ein erneutes Login muss die Anwendung neu geladen werden.<br/>' +
+                        'Alle ungesicherten Daten gehen dabei verloren.<br/>' +
+                        'Soll die Anwendung jetzt neu geladen werden?', this.reload);
                 }
             }
         }
         this.callParent(arguments);
+    },
+    reload: function(btn) {
+        if (btn === 'yes') {
+            location.reload();
+        }
     }
 });


More information about the Lada-commits mailing list