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', andre@608: andre@608: buildRequest: function (operation) { andre@608: this.headers = { 'X-OPENID-PARAMS': Lada.openIDParams }; andre@608: return this.callParent(arguments); andre@608: }, andre@608: andre@608: processResponse: function (success, operation, request, response, callback, scope) { andre@618: /* Check if we were authenticated at one point (Lada.openIDParams) and andre@618: * if the response means that we lost that authentcation */ andre@618: if (Lada.openIDParams && !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 andre@608: * 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 andre@608: * handle it here with relaunch. */ andre@618: Ext.MessageBox.confirm('Erneutes Login erforderlich', andre@618: 'Der Server konnte die Anfrage nicht authentifizieren.
'+ 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: }, andre@618: reload: function(btn) { andre@618: if (btn === 'yes') { andre@618: location.reload(); andre@618: } andre@608: } andre@608: });