summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@openerp.com>2012-10-15 18:23:46 +0200
committerChristophe Simonis <chs@openerp.com>2012-10-15 18:23:46 +0200
commit3adab7ba8c71cd222e9f9b56cb50b8d7fdfe3ff8 (patch)
treea993417dd60abbc4afc6d102bfdee556080a38c2 /addons/web/static/src/js
parentbc1a3dff21bf7bdb4c67aa1ad5e3bca237d4945c (diff)
[IMP]: once bound, a session cannot be bound to another server
bzr revid: chs@openerp.com-20121015162346-jwhctk988fftjsa4
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/chrome.js24
-rw-r--r--addons/web/static/src/js/coresetup.js6
2 files changed, 24 insertions, 6 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js
index 2b37ea9999a..5aa8be480d3 100644
--- a/addons/web/static/src/js/chrome.js
+++ b/addons/web/static/src/js/chrome.js
@@ -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) {
diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js
index 1f1112df2f2..cf533ed0b59 100644
--- a/addons/web/static/src/js/coresetup.js
+++ b/addons/web/static/src/js/coresetup.js
@@ -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;