andre@608: /* Copyright (C) 2015 by Bundesamt fuer Strahlenschutz
andre@608: * Software engineering by Intevation GmbH
andre@608: *
andre@608: * This file is Free Software under the GNU GPL (v>=3)
andre@608: * and comes with ABSOLUTELY NO WARRANTY! Check out
andre@608: * the documentation coming with IMIS-Labordaten-Application for details.
andre@608: */
andre@608:
andre@608: Ext.define('Lada.override.RestProxy', {
andre@608: override: 'Ext.data.proxy.Rest',
raimund@913: /*
andre@608: buildRequest: function (operation) {
andre@608: this.headers = { 'X-OPENID-PARAMS': Lada.openIDParams };
andre@608: return this.callParent(arguments);
andre@608: },
rrenkert@917: */
andre@608: processResponse: function (success, operation, request, response, callback, scope) {
andre@618: /* Check if we were authenticated at one point (Lada.openIDParams) and
rrenkert@917: * if the response means that we lost that authentcation */
rrenkert@917: if (!success && response.status == 401) {
andre@608: var json = Ext.decode(response.responseText);
andre@608: if (json) {
andre@618: if (json.message === "699" || json.message === "698") {
andre@608: /* This is the unauthorized message with the authentication
rrenkert@917: * redirect in the data */
andre@608:
andre@608: /* We decided to handle this with a redirect to the identity
andre@608: * provider. In which case we have no other option then to
rrenkert@917: * handle it here with relaunch. */
andre@618: Ext.MessageBox.confirm('Erneutes Login erforderlich',
rrenkert@917: 'Ihre Session ist abgelaufen.
'+
andre@618: 'Für ein erneutes Login muss die Anwendung neu geladen werden.
' +
andre@618: 'Alle ungesicherten Daten gehen dabei verloren.
' +
andre@618: 'Soll die Anwendung jetzt neu geladen werden?', this.reload);
andre@608: }
andre@608: }
andre@608: }
andre@608: this.callParent(arguments);
andre@618: },
rrenkert@917:
andre@618: reload: function(btn) {
andre@618: if (btn === 'yes') {
andre@618: location.reload();
andre@618: }
andre@608: }
andre@608: });