[IMP]: once bound, a session cannot be bound to another server

bzr revid: chs@openerp.com-20121015162346-jwhctk988fftjsa4
This commit is contained in:
Christophe Simonis
2012-10-15 18:23:46 +02:00
parent bc1a3dff21
commit 3adab7ba8c
2 changed files with 24 additions and 6 deletions
+18 -6
View File
@@ -1153,17 +1153,14 @@ instance.web.EmbeddedClient = instance.web.Client.extend({
_template: 'EmbedClient',
init: function(parent, origin, dbname, login, key, action_id, options) {
this._super(parent, origin);
this.dbname = dbname;
this.login = login;
this.key = key;
this.bind(dbname, login, key);
this.action_id = action_id;
this.options = options || {};
},
start: function() {
var self = this;
return $.when(this._super()).pipe(function() {
return instance.session.session_authenticate(self.dbname, self.login, self.key, true).pipe(function() {
return self.authenticate().pipe(function() {
if (!self.action_id) {
return;
}
@@ -1185,7 +1182,22 @@ instance.web.EmbeddedClient = instance.web.Client.extend({
do_action: function(action) {
return this.action_manager.do_action(action);
}
},
authenticate: function() {
var s = instance.session;
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);
},
bind: function(dbname, login, key) {
this.dbname = dbname;
this.login = login;
this.key = key;
},
});
instance.web.embed = function (origin, dbname, login, key, action, options) {
+6
View File
@@ -27,6 +27,12 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
* Setup a sessionm
*/
session_bind: function(origin) {
if (!_.isUndefined(this.origin)) {
if (this.origin === origin) {
return $.when();
}
throw new Error('Session already bound to ' + this.origin);
}
var self = this;
this.setup(origin);
instance.web.qweb.default_dict['_s'] = this.origin;