annotate app/override/RestProxy.js @ 842:beef4e8eeafc

Added logic to autofill the Netzbetreiber when the Messstelle was selected.
author Dustin Demuth <dustin@intevation.de>
date Tue, 07 Jul 2015 09:55:37 +0200
parents fb89f61ab272
children 44d7822d0d55
rev   line source
608
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2015 by Bundesamt fuer Strahlenschutz
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
3 *
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
7 */
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
8
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
9 Ext.define('Lada.override.RestProxy', {
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
10 override: 'Ext.data.proxy.Rest',
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
11
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
12 buildRequest: function (operation) {
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
13 this.headers = { 'X-OPENID-PARAMS': Lada.openIDParams };
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
14 return this.callParent(arguments);
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
15 },
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
16
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
17 processResponse: function (success, operation, request, response, callback, scope) {
618
fb89f61ab272 Improve error handling on authentication loss.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 608
diff changeset
18 /* Check if we were authenticated at one point (Lada.openIDParams) and
fb89f61ab272 Improve error handling on authentication loss.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 608
diff changeset
19 * if the response means that we lost that authentcation */
fb89f61ab272 Improve error handling on authentication loss.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 608
diff changeset
20 if (Lada.openIDParams && !success && response.status == 401) {
608
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
21 var json = Ext.decode(response.responseText);
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
22 if (json) {
618
fb89f61ab272 Improve error handling on authentication loss.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 608
diff changeset
23 if (json.message === "699" || json.message === "698") {
608
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
24 /* This is the unauthorized message with the authentication
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
25 * redirect in the data */
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
26
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
27 /* We decided to handle this with a redirect to the identity
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
28 * provider. In which case we have no other option then to
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
29 * handle it here with relaunch. */
618
fb89f61ab272 Improve error handling on authentication loss.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 608
diff changeset
30 Ext.MessageBox.confirm('Erneutes Login erforderlich',
fb89f61ab272 Improve error handling on authentication loss.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 608
diff changeset
31 'Der Server konnte die Anfrage nicht authentifizieren.<br/>'+
fb89f61ab272 Improve error handling on authentication loss.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 608
diff changeset
32 'Für ein erneutes Login muss die Anwendung neu geladen werden.<br/>' +
fb89f61ab272 Improve error handling on authentication loss.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 608
diff changeset
33 'Alle ungesicherten Daten gehen dabei verloren.<br/>' +
fb89f61ab272 Improve error handling on authentication loss.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 608
diff changeset
34 'Soll die Anwendung jetzt neu geladen werden?', this.reload);
608
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
35 }
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
36 }
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
37 }
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
38 this.callParent(arguments);
618
fb89f61ab272 Improve error handling on authentication loss.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 608
diff changeset
39 },
fb89f61ab272 Improve error handling on authentication loss.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 608
diff changeset
40 reload: function(btn) {
fb89f61ab272 Improve error handling on authentication loss.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 608
diff changeset
41 if (btn === 'yes') {
fb89f61ab272 Improve error handling on authentication loss.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 608
diff changeset
42 location.reload();
fb89f61ab272 Improve error handling on authentication loss.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 608
diff changeset
43 }
608
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
44 }
7fd9350eacf9 Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
45 });

http://lada.wald.intevation.org