Mercurial > lada > lada-client
annotate app/override/RestProxy.js @ 918:9358c5feb843
2.1.1
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Fri, 14 Aug 2015 10:34:49 +0200 |
parents | 2bf35377414a |
children | f220ba587c89 |
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', |
913
44d7822d0d55
Removed OpenId stuff.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
618
diff
changeset
|
11 /* |
608
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 }, |
917
2bf35377414a
Use rest response handler to act on unauthenticated request.
Raimund Renkert <rrenkert@intevation.de>
parents:
913
diff
changeset
|
16 */ |
608
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 |
917
2bf35377414a
Use rest response handler to act on unauthenticated request.
Raimund Renkert <rrenkert@intevation.de>
parents:
913
diff
changeset
|
19 * if the response means that we lost that authentcation */ |
2bf35377414a
Use rest response handler to act on unauthenticated request.
Raimund Renkert <rrenkert@intevation.de>
parents:
913
diff
changeset
|
20 if (!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 |
917
2bf35377414a
Use rest response handler to act on unauthenticated request.
Raimund Renkert <rrenkert@intevation.de>
parents:
913
diff
changeset
|
25 * redirect in the data */ |
608
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 |
917
2bf35377414a
Use rest response handler to act on unauthenticated request.
Raimund Renkert <rrenkert@intevation.de>
parents:
913
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', |
917
2bf35377414a
Use rest response handler to act on unauthenticated request.
Raimund Renkert <rrenkert@intevation.de>
parents:
913
diff
changeset
|
31 'Ihre Session ist abgelaufen.<br/>'+ |
618
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 }, |
917
2bf35377414a
Use rest response handler to act on unauthenticated request.
Raimund Renkert <rrenkert@intevation.de>
parents:
913
diff
changeset
|
40 |
618
fb89f61ab272
Improve error handling on authentication loss.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
608
diff
changeset
|
41 reload: function(btn) { |
fb89f61ab272
Improve error handling on authentication loss.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
608
diff
changeset
|
42 if (btn === 'yes') { |
fb89f61ab272
Improve error handling on authentication loss.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
608
diff
changeset
|
43 location.reload(); |
fb89f61ab272
Improve error handling on authentication loss.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
608
diff
changeset
|
44 } |
608
7fd9350eacf9
Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
45 } |
7fd9350eacf9
Add client side openID authentication handling
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
46 }); |