Commit 86d8cb0b authored by Roque's avatar Roque

erp5_officejs: fix in jio local gadget 401 redirect

parent 2b7a3144
...@@ -3,16 +3,7 @@ ...@@ -3,16 +3,7 @@
(function (window, rJS, jIO, RSVP, UriTemplate, console) { (function (window, rJS, jIO, RSVP, UriTemplate, console) {
"use strict"; "use strict";
// jIO call wrapper for redirection to authentication page if needed function redirectToLogin(gadget, error) {
function wrapJioCall(gadget, method_name, argument_list) {
var storage = gadget.state_parameter_dict.jio_storage;
if (storage === undefined) {
return gadget.redirect({command: 'display',
options: {page: 'ojs_configurator'}});
}
return storage[method_name].apply(storage, argument_list)
.push(undefined, function (error) {
if ((error.target !== undefined) && (error.target.status === 401)) {
var regexp, var regexp,
site, site,
login_page; login_page;
...@@ -59,6 +50,19 @@ ...@@ -59,6 +50,19 @@
options: {page: 'ojs_configurator'}}); options: {page: 'ojs_configurator'}});
}); });
} }
// jIO call wrapper for redirection to authentication page if needed
function wrapJioCall(gadget, method_name, argument_list) {
var storage = gadget.state_parameter_dict.jio_storage;
if (storage === undefined) {
return gadget.redirect({command: 'display',
options: {page: 'ojs_configurator'}});
}
return storage[method_name].apply(storage, argument_list)
.push(undefined, function (error) {
if ((error.target !== undefined) && (error.target.status === 401)) {
return redirectToLogin(gadget, error);
}
throw error; throw error;
}); });
} }
...@@ -188,6 +192,7 @@ ...@@ -188,6 +192,7 @@
} }
if (result_list[0] === undefined) { return; } if (result_list[0] === undefined) { return; }
if (result_list[1] === undefined) { return; } if (result_list[1] === undefined) { return; }
gadget.state_parameter_dict.jio_storage_name = result_list[1];
appcache_storage = jIO.createJIO(jio_appchache_options); appcache_storage = jIO.createJIO(jio_appchache_options);
}) })
.push(function () { .push(function () {
...@@ -200,14 +205,11 @@ ...@@ -200,14 +205,11 @@
} }
}) })
.push(undefined, function (error) { .push(undefined, function (error) {
console.log("Error while appcache-local " + console.log("Error while appcache-local storage synchronization");
"storage synchronization");
if (error && error.currentTarget && if (error && error.currentTarget &&
error.currentTarget.status === 401) { error.currentTarget.status === 401) {
console.log("Unauthorized access to storage," + console.log("Unauthorized access to storage, sync cancelled");
"sync cancelled"); return redirectToLogin(gadget, error);
gadget.state_parameter_dict.jio_storage_name = "ERP5";
return;
} }
console.log(error); console.log(error);
throw error; throw error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment