65 |
65 |
create_menu_items();
|
66 |
66 |
} else {
|
67 |
67 |
var this_hostname = window.location.hostname;
|
|
68 |
var look_for_wcs = false;
|
|
69 |
var authentic_url = undefined;
|
|
70 |
|
68 |
71 |
$(COMBO_KNOWN_SERVICES).each(function(index, element) {
|
69 |
72 |
if (element.backoffice_menu_url === null) {
|
70 |
73 |
element.data = Array();
|
... | ... | |
77 |
80 |
*/
|
78 |
81 |
var that_hostname = $('<a>').attr('href', element.backoffice_menu_url)[0].hostname;
|
79 |
82 |
if (that_hostname != this_hostname) {
|
|
83 |
look_for_wcs = true;
|
80 |
84 |
element.data = Array();
|
81 |
85 |
check_all_done();
|
82 |
86 |
return;
|
83 |
87 |
}
|
84 |
88 |
}
|
85 |
89 |
|
|
90 |
if (element.service_id === 'authentic') {
|
|
91 |
authentic_url = element.url;
|
|
92 |
}
|
|
93 |
|
86 |
94 |
$.ajax({url: element.backoffice_menu_url,
|
87 |
95 |
xhrFields: { withCredentials: true },
|
88 |
96 |
async: true,
|
... | ... | |
93 |
101 |
}
|
94 |
102 |
);
|
95 |
103 |
});
|
|
104 |
if (look_for_wcs && authentic_url) {
|
|
105 |
/* if there is several wcs instances, we ask authentic for details on the
|
|
106 |
* user, to get the services where the user has some roles
|
|
107 |
*/
|
|
108 |
$.ajax({url: authentic_url + 'user_info/',
|
|
109 |
xhrFields: { withCredentials: true },
|
|
110 |
async: true,
|
|
111 |
dataType: 'jsonp',
|
|
112 |
crossDomain: true,
|
|
113 |
success: function(data) {
|
|
114 |
var services_to_consider = Array();
|
|
115 |
/* iterate over all services, to get those to consider */
|
|
116 |
$(COMBO_KNOWN_SERVICES).each(function(index, element) {
|
|
117 |
if (element.service_id !== 'wcs') return;
|
|
118 |
$(data.services).each(function(auth_index, auth_element) {
|
|
119 |
if (auth_element.slug !== element.slug) return;
|
|
120 |
if (auth_element.roles.length == 0) return;
|
|
121 |
services_to_consider.push(element);
|
|
122 |
});
|
|
123 |
});
|
|
124 |
if (services_to_consider.length == 1) {
|
|
125 |
/* only handle the case with a single service, for now */
|
|
126 |
var element = services_to_consider[0];
|
|
127 |
$.ajax({url: element.backoffice_menu_url,
|
|
128 |
xhrFields: { withCredentials: true },
|
|
129 |
async: true,
|
|
130 |
dataType: 'jsonp',
|
|
131 |
crossDomain: true,
|
|
132 |
success: function(data) { element.data = data; check_all_done(); },
|
|
133 |
error: function(error) { console.log('bouh', error); element.data = Array(); check_all_done(); }
|
|
134 |
}
|
|
135 |
);
|
|
136 |
}
|
|
137 |
},
|
|
138 |
error: function(error) { console.log('bouh', error); }
|
|
139 |
}
|
|
140 |
);
|
|
141 |
}
|
96 |
142 |
}
|
97 |
143 |
|
98 |
144 |
var sidepage_button = $('#sidepage #applabel');
|
99 |
|
-
|