comparison app/override/RestProxy.js @ 673:39dd18124ebd

Merged branch openid back to default.
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 19 Mar 2015 14:31:07 +0100
parents fb89f61ab272
children 44d7822d0d55
comparison
equal deleted inserted replaced
657:74cc7f086d83 673:39dd18124ebd
1 /* Copyright (C) 2015 by Bundesamt fuer Strahlenschutz
2 * Software engineering by Intevation GmbH
3 *
4 * This file is Free Software under the GNU GPL (v>=3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
6 * the documentation coming with IMIS-Labordaten-Application for details.
7 */
8
9 Ext.define('Lada.override.RestProxy', {
10 override: 'Ext.data.proxy.Rest',
11
12 buildRequest: function (operation) {
13 this.headers = { 'X-OPENID-PARAMS': Lada.openIDParams };
14 return this.callParent(arguments);
15 },
16
17 processResponse: function (success, operation, request, response, callback, scope) {
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) {
21 var json = Ext.decode(response.responseText);
22 if (json) {
23 if (json.message === "699" || json.message === "698") {
24 /* This is the unauthorized message with the authentication
25 * redirect in the data */
26
27 /* We decided to handle this with a redirect to the identity
28 * provider. In which case we have no other option then to
29 * handle it here with relaunch. */
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);
35 }
36 }
37 }
38 this.callParent(arguments);
39 },
40 reload: function(btn) {
41 if (btn === 'yes') {
42 location.reload();
43 }
44 }
45 });

http://lada.wald.intevation.org