Commit 1b6fd549 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Reactivate automatic redirection to the login page

This redirection is specific to each application (cookie, token, erp5, another backend, etc)
parent 17ccfaaf
......@@ -102,7 +102,7 @@
<value> <string encoding="cdata"><![CDATA[
CACHE MANIFEST\n
# generated on Tue, 27 Oct 2015 10:23:59 +0000\n
# generated on Thu, 29 Oct 2015 14:10:37 +0000\n
# XXX + fonts\n
# images/ajax-loader.gif\n
CACHE:\n
......@@ -359,7 +359,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>946.45949.63639.28723</string> </value>
<value> <string>946.49074.40798.4676</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -377,7 +377,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1445941439.32</float>
<float>1446127880.43</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -105,6 +105,17 @@
/*jslint indent: 2, maxerr: 3, nomen: true */\n
(function (window, rJS, RSVP, UriTemplate, URI) {\n
"use strict";\n
\n
function wrapJioCall(gadget, method_name, argument_list) {\n
var storage = gadget.state_parameter_dict.jio_storage;\n
return storage[method_name].apply(storage, argument_list)\n
.push(undefined, function (error) {\n
if ((error.target !== undefined) && (error.target.status === 401)) {\n
// Redirect to the login view\n
return gadget.redirect({command: \'display\', options: {page: \'login\'}});\n
}\n
});\n
}\n
\n
rJS(window)\n
\n
......@@ -117,6 +128,7 @@
})\n
\n
.declareAcquiredMethod(\'getSetting\', \'getSetting\')\n
.declareAcquiredMethod(\'redirect\', \'redirect\')\n
\n
.declareMethod(\'createJio\', function () {\n
var gadget = this;\n
......@@ -138,17 +150,20 @@
\n
.declareMethod(\'allDocs\', function (option_dict) {\n
// throw new Error(\'do not use all docs\');\n
var storage = this.state_parameter_dict.jio_storage;\n
\n
if (option_dict.list_method_template === undefined) {\n
return storage.allDocs.apply(storage, arguments);\n
return wrapJioCall(this, \'allDocs\', arguments);\n
}\n
return storage.getAttachment(\n
// XXX Ugly hardcoded meaningless id...\n
"erp5",\n
new UriTemplate.parse(option_dict.list_method_template)\n
.expand(option_dict),\n
{format: "json"}\n
return wrapJioCall(\n
this,\n
\'getAttachment\',\n
[\n
// XXX Ugly hardcoded meaningless id...\n
"erp5",\n
new UriTemplate.parse(option_dict.list_method_template)\n
.expand(option_dict),\n
{format: "json"}\n
]\n
)\n
.push(function (catalog_json) {\n
var data = catalog_json._embedded.contents,\n
......@@ -176,10 +191,10 @@
});\n
})\n
.declareMethod(\'getAttachment\', function (id, name) {\n
return this.state_parameter_dict.jio_storage.getAttachment(id, name, {format: "json"});\n
return wrapJioCall(this, \'getAttachment\', [id, name, {format: "json"}]);\n
})\n
.declareMethod(\'putAttachment\', function (id, name, json) {\n
return this.state_parameter_dict.jio_storage.putAttachment(id, name, JSON.stringify(json));\n
return wrapJioCall(this, \'putAttachment\', [id, name, JSON.stringify(json)]);\n
});\n
\n
}(window, rJS, RSVP, UriTemplate, URI));
......@@ -305,7 +320,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>romain</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -319,7 +334,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>946.24288.2744.26624</string> </value>
<value> <string>946.49070.15531.48588</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -337,8 +352,8 @@
</tuple>
<state>
<tuple>
<float>1444640714.39</float>
<string>GMT</string>
<float>1446127591.78</float>
<string>UTC</string>
</tuple>
</state>
</object>
......
......@@ -161,7 +161,7 @@
\n
document.cookie = "__ac=" + window.btoa(login + ":" + passwd);\n
// XXX Hardcoded non generic redirection to the frontpage\n
return form_gadget.redirect({});\n
return form_gadget.redirect({command: \'display\', options: {}});\n
});\n
\n
});\n
......@@ -286,7 +286,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>romain</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -300,7 +300,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.43780.3884.33979</string> </value>
<value> <string>946.44927.40202.16725</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -318,8 +318,8 @@
</tuple>
<state>
<tuple>
<float>1442484467.19</float>
<string>GMT</string>
<float>1446127708.36</float>
<string>UTC</string>
</tuple>
</state>
</object>
......
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