comparison app/override/RestProxy.js @ 618:fb89f61ab272 openid

Improve error handling on authentication loss.
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 13 Mar 2015 17:17:09 +0100
parents 7fd9350eacf9
children 44d7822d0d55
comparison
equal deleted inserted replaced
617:ab48824713e2 618:fb89f61ab272
13 this.headers = { 'X-OPENID-PARAMS': Lada.openIDParams }; 13 this.headers = { 'X-OPENID-PARAMS': Lada.openIDParams };
14 return this.callParent(arguments); 14 return this.callParent(arguments);
15 }, 15 },
16 16
17 processResponse: function (success, operation, request, response, callback, scope) { 17 processResponse: function (success, operation, request, response, callback, scope) {
18 if (!success && response.status == 401) { 18 /* Check if we were authenticated at one point (Lada.openIDParams) and
19 * if the response means that we lost that authentcation */
20 if (Lada.openIDParams && !success && response.status == 401) {
19 var json = Ext.decode(response.responseText); 21 var json = Ext.decode(response.responseText);
20 if (json) { 22 if (json) {
21 if (json.message == "699") { 23 if (json.message === "699" || json.message === "698") {
22 /* This is the unauthorized message with the authentication 24 /* This is the unauthorized message with the authentication
23 * redirect in the data */ 25 * redirect in the data */
24 26
25 /* We decided to handle this with a redirect to the identity 27 /* We decided to handle this with a redirect to the identity
26 * provider. In which case we have no other option then to 28 * provider. In which case we have no other option then to
27 * handle it here with relaunch. */ 29 * handle it here with relaunch. */
28 Lada.launch(); // Data loss! 30 Ext.MessageBox.confirm('Erneutes Login erforderlich',
31 'Der Server konnte die Anfrage nicht authentifizieren.<br/>'+
32 'Für ein erneutes Login muss die Anwendung neu geladen werden.<br/>' +
33 'Alle ungesicherten Daten gehen dabei verloren.<br/>' +
34 'Soll die Anwendung jetzt neu geladen werden?', this.reload);
29 } 35 }
30 } 36 }
31 } 37 }
32 this.callParent(arguments); 38 this.callParent(arguments);
39 },
40 reload: function(btn) {
41 if (btn === 'yes') {
42 location.reload();
43 }
33 } 44 }
34 }); 45 });

http://lada.wald.intevation.org