summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/coresetup.js
diff options
context:
space:
mode:
authorniv-openerp <nicolas.vanhoren@openerp.com>2013-07-12 14:07:27 +0200
committerniv-openerp <nicolas.vanhoren@openerp.com>2013-07-12 14:07:27 +0200
commit17db55200b31494427d26803da93b59be90c239d (patch)
treef7b76a8121b314133e012b7fdb63c2abfdc4a823 /addons/web/static/src/js/coresetup.js
parent12f58092f2df0d7236dbadf346765bcb37ae5929 (diff)
parenta7ab235c3a88dc817d61c526b9474c5537d5ed61 (diff)
[IMP] Modified the way the sessions are handled to easily work with or without cookies
bzr revid: nicolas.vanhoren@openerp.com-20130712120727-z1hj46m7m807nal1
Diffstat (limited to 'addons/web/static/src/js/coresetup.js')
-rw-r--r--addons/web/static/src/js/coresetup.js25
1 files changed, 17 insertions, 8 deletions
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) {