diff options
| author | Frédéric van der Essen <fva@openerp.com> | 2013-07-12 14:11:48 +0200 |
|---|---|---|
| committer | Frédéric van der Essen <fva@openerp.com> | 2013-07-12 14:11:48 +0200 |
| commit | 16d3b79dfd293a0430efb7cd97dd62944853c86b (patch) | |
| tree | b350ac948f708c73ff21c3f6708e655c97e2f413 /addons/web/static/src/js | |
| parent | ccc2dd61ced6a76334458be6056bc94075964cbe (diff) | |
| parent | 17db55200b31494427d26803da93b59be90c239d (diff) | |
[MERGE] from upstream
bzr revid: fva@openerp.com-20130712121148-0ys14v8jc33t6sf5
Diffstat (limited to 'addons/web/static/src/js')
| -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 |
3 files changed, 31 insertions, 29 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) { |
