comparison app/controller/FilterResult.js @ 920:f220ba587c89

Adopted Client to SSO, detect a Sessiontimeout and reload the application
author Dustin Demuth <dustin@intevation.de>
date Fri, 14 Aug 2015 13:27:50 +0200
parents 2b7bcb778f0a
children 7cbbe0485d0d
comparison
equal deleted inserted replaced
919:c8599a543f03 920:f220ba587c89
168 var me = this; 168 var me = this;
169 Ext.Ajax.request({ 169 Ext.Ajax.request({
170 method: 'POST', 170 method: 'POST',
171 url: 'lada-server/export/laf', 171 url: 'lada-server/export/laf',
172 jsonData: {'proben': proben}, 172 jsonData: {'proben': proben},
173 headers: {'X-OPENID-PARAMS': Lada.openIDParams},
174 success: function(response) { 173 success: function(response) {
175 var content = response.responseText; 174 var content = response.responseText;
176 var blob = new Blob([content],{type: 'text/plain'}); 175 var blob = new Blob([content],{type: 'text/plain'});
177 saveAs(blob, 'export.laf'); 176 saveAs(blob, 'export.laf');
178 }, 177 },
179 failure: function(response) { 178 failure: function(response) {
179 /*
180 SSO will send a 302 if the Client is not authenticated
181 unfortunately this seems to be filtered by the browser.
182 We assume that a 302 was send when the follwing statement
183 is true.
184 */
185 if (response.status == 0 && response.responseText === "") {
186 Ext.MessageBox.confirm('Erneutes Login erforderlich',
187 'Ihre Session ist abgelaufen.<br/>'+
188 'Für ein erneutes Login muss die Anwendung neu geladen werden.<br/>' +
189 'Alle ungesicherten Daten gehen dabei verloren.<br/>' +
190 'Soll die Anwendung jetzt neu geladen werden?', this.reload);
191 }
192 // further error handling
180 var json = Ext.JSON.decode(response.responseText); 193 var json = Ext.JSON.decode(response.responseText);
181 if (json) { 194 if (json) {
182 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ 195 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){
183 formPanel.setMessages(json.errors, json.warnings); 196 formPanel.setMessages(json.errors, json.warnings);
184 } 197 }
185 // TODO Move this handling of 699 and 698 to a more central place! 198 if(json.message){
186 // TODO i18n
187 if (json.message === "699" || json.message === "698") {
188 /* This is the unauthorized message with the authentication
189 * redirect in the data */
190
191 /* We decided to handle this with a redirect to the identity
192 * provider. In which case we have no other option then to
193 * handle it here with relaunch. */
194 Ext.MessageBox.confirm('Erneutes Login erforderlich',
195 'Der Server konnte die Anfrage nicht authentifizieren.<br/>'+
196 'Für ein erneutes Login muss die Anwendung neu geladen werden.<br/>' +
197 'Alle ungesicherten Daten gehen dabei verloren.<br/>' +
198 'Soll die Anwendung jetzt neu geladen werden?', me.reload);
199 }
200 else if(json.message){
201 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title') 199 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title')
202 +' #'+json.message, 200 +' #'+json.message,
203 Lada.getApplication().bundle.getMsg(json.message)); 201 Lada.getApplication().bundle.getMsg(json.message));
204 } else { 202 } else {
205 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), 203 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),

http://lada.wald.intevation.org