From a7adac1189d062ad8797b8d7ead929b27715cf3c Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 11 Jul 2013 12:34:22 +0200 Subject: Now OpenERPSession is a subclass of werkzeug's session bzr revid: nicolas.vanhoren@openerp.com-20130711103422-w7y05ox7tq0hz0og --- addons/web/static/src/js/coresetup.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'addons/web/static/src/js/coresetup.js') diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index 7d37dc2261d..81de547d0c1 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -58,7 +58,7 @@ 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'); + this.session_id = this.get_cookie('sid'); 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)); @@ -107,14 +107,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", {}); }, -- cgit v1.2.3 From 47b5a82ae85e795ae888799426f098066583ecbc Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 11 Jul 2013 14:20:34 +0200 Subject: Completely removed all ways to specify session identifiers and reduced them to 2 possibilities: * The http argument 'session_id' (higher priority) * The cookie 'session_id' (lower priority) bzr revid: nicolas.vanhoren@openerp.com-20130711122034-3nvmkw4q5z4io4tm --- addons/web/static/src/js/coresetup.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'addons/web/static/src/js/coresetup.js') diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index 81de547d0c1..f153d3ad73a 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); }, /** @@ -58,7 +57,7 @@ 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('sid'); + 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)); -- cgit v1.2.3 From a7ab235c3a88dc817d61c526b9474c5537d5ed61 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 12 Jul 2013 11:53:09 +0200 Subject: changed session handling bzr revid: nicolas.vanhoren@openerp.com-20130712095309-41u7fi7ecs0y1lm1 --- addons/web/static/src/js/coresetup.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'addons/web/static/src/js/coresetup.js') diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index f153d3ad73a..3ba5855533f 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -38,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) { @@ -56,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)); @@ -80,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...) @@ -326,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) { -- cgit v1.2.3