diff options
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/chrome.js | 2 | ||||
| -rw-r--r-- | addons/web/static/src/js/corelib.js | 28 | ||||
| -rw-r--r-- | addons/web/static/src/js/coresetup.js | 30 | ||||
| -rw-r--r-- | addons/web/static/src/xml/base.xml | 8 |
4 files changed, 35 insertions, 33 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 0c73a9b8a3c..1c976cb619e 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -1599,7 +1599,7 @@ instance.web.EmbeddedClient = instance.web.Client.extend({ if (s.session_is_valid() && s.db === this.dbname && s.login === this.login) { return $.when(); } - return instance.session.session_authenticate(this.dbname, this.login, this.key, true); + return instance.session.session_authenticate(this.dbname, this.login, this.key); }, bind_credentials: function(dbname, login, key) { diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js index 1575065a9dd..58c2969bb20 100644 --- a/addons/web/static/src/js/corelib.js +++ b/addons/web/static/src/js/corelib.js @@ -967,6 +967,8 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, { instance.web.PropertiesMixin.init.call(this); this.server = null; this.debug = ($.deparam($.param.querystring()).debug != undefined); + this.override_session = false; + this.session_id = undefined; }, setup: function(origin) { var window_origin = location.protocol+"//"+location.host, self=this; @@ -1000,8 +1002,6 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, { context: this.user_context || {} }); // Construct a JSON-RPC2 request, method is currently unused - if (this.debug) - params.debug = 1; var payload = { jsonrpc: '2.0', method: 'call', @@ -1059,7 +1059,10 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, { dataType: 'json', contentType: 'application/json', data: JSON.stringify(payload), - processData: false + processData: false, + headers: { + "X-Openerp-Session-Id": this.override_session ? this.session_id : undefined, + }, }, url); if (this.synch) ajax.async = false; @@ -1071,13 +1074,12 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, { var data = { session_id: this.session_id, id: payload.id, - sid: this.httpsessionid, }; var set_sid = function (response, textStatus, jqXHR) { // If response give us the http session id, we store it for next requests... - if (response.httpsessionid) { - self.httpsessionid = response.httpsessionid; + if (response.session_id) { + self.session_id = response.session_id; } }; @@ -1093,7 +1095,7 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, { ajax.async = false; var payload_str = JSON.stringify(payload); var payload_url = $.param({r:payload_str}); - if(payload_url.length < 2000) { + if (payload_url.length < 2000) { // Direct jsonp request ajax.data.r = payload_str; return $.ajax(ajax).done(set_sid); @@ -1139,14 +1141,10 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, { }, url: function(path, params) { - var qs = ''; - if (!_.isNull(params)) { - params = _.extend(params || {}, {session_id: this.session_id}); - if (this.httpsessionid) { - params.sid = this.httpsessionid; - } - qs = '?' + $.param(params); - } + params = _.extend(params || {}); + if (this.override_session) + params.session_id = this.session_id; + var qs = '?' + $.param(params); var prefix = _.any(['http://', 'https://', '//'], _.bind(_.str.startsWith, null, path)) ? '' : this.prefix; return prefix + path + qs; }, diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index 7d37dc2261d..3ba5855533f 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -23,7 +23,6 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess this.qweb_mutex = new $.Mutex(); }, rpc: function(url, params, options) { - params.session_id = this.session_id; return this._super(url, params, options); }, /** @@ -39,11 +38,10 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess var self = this; this.setup(origin); instance.web.qweb.default_dict['_s'] = this.origin; - this.session_id = false; - this.uid = false; - this.username = false; + this.uid = null; + this.username = null; this.user_context= {}; - this.db = false; + this.db = null; this.module_list = instance._modules.slice(); this.module_loaded = {}; _(this.module_list).each(function (mod) { @@ -57,8 +55,6 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess */ session_init: function () { var self = this; - // TODO: session store in cookie should be optional - this.session_id = this.get_cookie('session_id'); return this.session_reload().then(function(result) { var modules = instance._modules.join(','); var deferred = self.rpc('/web/webclient/qweblist', {mods: modules}).then(self.load_qweb.bind(self)); @@ -81,7 +77,19 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess */ session_reload: function () { var self = this; - return this.rpc("/web/session/get_session_info", {}).done(function(result) { + var def = $.when(); + if (this.override_session) { + if (! this.session_id) { + def = this.rpc("/gen_session_id", {}).then(function(result) { + self.session_id = result; + }); + } + } else { + this.session_id = this.get_cookie('session_id'); + } + return def.then(function() { + return self.rpc("/web/session/get_session_info", {}) + }).then(function(result) { // If immediately follows a login (triggered by trying to restore // an invalid session or no session at all), refresh session data // (should not change, but just in case...) @@ -107,14 +115,10 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess return $.Deferred().reject(); } _.extend(self, result); - if (!_volatile) { - self.set_cookie('session_id', self.session_id); - } return self.load_modules(); }); }, session_logout: function() { - this.set_cookie('session_id', ''); $.bbq.removeState(); return this.rpc("/web/session/destroy", {}); }, @@ -331,7 +335,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess } _(_.extend({}, options.data || {}, - {session_id: this.session_id, token: token})) + {session_id: this.override_session ? this.session_id : undefined, token: token})) .each(function (value, key) { var $input = $form.find('[name=' + key +']'); if (!$input.length) { diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index a459486bf05..643bca0e798 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -654,7 +654,7 @@ <t t-set="fileupload_action" t-translation="off">/web/binary/upload_attachment</t> <input type="hidden" name="model" t-att-value="widget.dataset and widget.dataset.model"/> <input type="hidden" name="id" t-att-value="widget.model_id"/> - <input type="hidden" name="session_id" t-att-value="widget.session.session_id"/> + <input type="hidden" name="session_id" t-att-value="widget.session.session_id" t-if="widget.session.override_session"/> <span>Add...</span> </t> </li> @@ -1320,7 +1320,7 @@ <div t-attf-class="oe_hidden_input_file #{fileupload_class or ''}" t-att-style="fileupload_style"> <form class="oe_form_binary_form" t-att-target="fileupload_id" method="post" enctype="multipart/form-data" t-att-action="fileupload_action || '/web/binary/upload'"> - <input type="hidden" name="session_id" value=""/> + <input type="hidden" name="session_id" value="" t-if="widget.session.override_session"/> <input type="hidden" name="callback" t-att-value="fileupload_id"/> <t t-raw="__content__"/> <input type="file" class="oe_form_binary_file" name="ufile" t-if="widget.widget!='image'"/> @@ -1372,7 +1372,7 @@ <t t-set="fileupload_action" t-translation="off">/web/binary/upload_attachment</t> <input type="hidden" name="model" t-att-value="widget.view.model"/> <input type="hidden" name="id" value="0"/> - <input type="hidden" name="session_id" t-att-value="widget.session.session_id"/> + <input type="hidden" name="session_id" t-att-value="widget.session.session_id" t-if="widget.session.override_session"/> </t> </div> </div> @@ -1835,7 +1835,7 @@ <t t-name="ImportDataView"> <form name="import_data" id="import_data" action="" method="post" enctype="multipart/form-data" class="oe_import oe_import_no_result"> - <input type="hidden" name="session_id" t-att-value="widget.session.session_id"/> + <input type="hidden" name="session_id" t-att-value="widget.session.session_id" t-if="widget.session.override_session"/> <h2 class="separator horizontal">1. Import a .CSV file</h2> <p>Select a .CSV file to import. If you need a sample of file to import, you should use the export tool with the "Import Compatible" option. |
