comparison app.js @ 673:39dd18124ebd

Merged branch openid back to default.
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 19 Mar 2015 14:31:07 +0100
parents 67963fcb7739 8756f7e423fb
children 60a3e9809ea4
comparison
equal deleted inserted replaced
657:74cc7f086d83 673:39dd18124ebd
21 21
22 // Setting up translations. This is done using a ext-plgin which can be 22 // Setting up translations. This is done using a ext-plgin which can be
23 // found on https://github.com/elmasse/Ext.i18n.Bundle 23 // found on https://github.com/elmasse/Ext.i18n.Bundle
24 requires: [ 24 requires: [
25 'Lada.override.Table', 25 'Lada.override.Table',
26 'Lada.override.RestProxy',
26 'Lada.override.RowEditor', 27 'Lada.override.RowEditor',
27 'Ext.i18n.Bundle', 28 'Ext.i18n.Bundle',
28 'Ext.layout.container.Column', 29 'Ext.layout.container.Column',
29 'Lada.store.Datenbasis', 30 'Lada.store.Datenbasis',
30 'Lada.store.Messeinheiten', 31 'Lada.store.Messeinheiten',
47 noCache: true 48 noCache: true
48 }, 49 },
49 50
50 // Setting this variable to true triggers loading the Viewport.js 51 // Setting this variable to true triggers loading the Viewport.js
51 // file which sets ob the viewport. 52 // file which sets ob the viewport.
52 autoCreateViewport: true, 53 //autoCreateViewport: true,
53 54
54 // Start the application. 55 // Start the application.
55 launch: function() { 56 launch: function() {
57 var queryString = document.location.href.split('?')[1];
58 if (queryString) {
59 Lada.openIDParams = queryString;
60 }
61 Ext.Ajax.request({
62 url: 'lada-server/login?return_to=' + window.location.href,
63 method: 'GET',
64 headers: {
65 'X-OPENID-PARAMS': Lada.openIDParams
66 },
67 scope: this,
68 success: this.onLoginSuccess,
69 failure: this.onLoginFailure
70 });
71 },
72
73 onLoginFailure: function(response) {
74 try {
75 var json = Ext.decode(response.responseText);
76 if (json) {
77 if (json.message === '699') {
78 /* This is the unauthorized message with the authentication
79 * redirect in the data */
80 var authUrl = json.data;
81 location.href = authUrl;
82 return;
83 }
84 if (json.message === '698') {
85 /* This is general authentication error */
86 Ext.MessageBox.alert('Kommunikation mit dem Login Server fehlgeschlagen',
87 json.data);
88 return;
89 }
90 }
91 }
92 catch (e) {
93 // This is likely a 404 or some unknown error. Show general error then.
94 }
95 Ext.MessageBox.alert('Kommunikation mit dem Lada Server fehlgeschlagen',
96 'Es konnte keine erfolgreiche Verbindung zum lada server aufgebaut werden.');
97 },
98
99 onLoginSuccess: function() {
100 /* Strip out the openid query params to look nicers. */
101 window.history.pushState(this.name, this.name, window.location.pathname);
102
103 Ext.create('Lada.view.Viewport');
104
105 /* Todo maybe parse username and such from login service response */
56 Ext.create('Lada.store.Datenbasis', { 106 Ext.create('Lada.store.Datenbasis', {
57 storeId: 'datenbasis' 107 storeId: 'datenbasis'
58 }); 108 });
59 Ext.create('Lada.store.Messeinheiten', { 109 Ext.create('Lada.store.Messeinheiten', {
60 storeId: 'messeinheiten' 110 storeId: 'messeinheiten'

http://lada.wald.intevation.org