do_login: function (db, login, password) {
var self = this;
this.session.session_authenticate(db, login, password).then(function() {
- if(self.session.is_valid()) {
+ if(self.session.session_is_valid()) {
if (self.has_local_storage) {
if(self.remember_credentials) {
localStorage.setItem('last_db_login_success', db);
// TODO: session store in cookie should be optional
this.name = openerp._session_id;
},
- bind: function(server) {
- if (this.server) {
- throw new Error("Connection already bound to " + this.server);
- }
-
- var hostname = _.str.sprintf('%s//%s', location.protocol, location.host);
- this.server = _.str.rtrim((!server) ? hostname : server, '/');
- openerp.web.qweb.default_dict['_s'] = this.server;
- this.rpc_function = (this.server == hostname) ? this.rpc_json : this.rpc_jsonp;
-
- this.prefix = this.server; // make al happy
-
+ bind: function(origin) {
+ var window_origin = location.protocol+"//"+location.host;
+ this.origin = origin ? _.str.rtrim(origin,'/') : window_origin;
+ this.prefix = this.origin;
+ this.server = this.origin; // keep chs happy
+ openerp.web.qweb.default_dict['_s'] = this.origin;
+ this.rpc_function = (this.origin == window_origin) ? this.rpc_json : this.rpc_jsonp;
this.session_id = false;
this.uid = false;
this.username = false;
this.ready = $.Deferred();
return this.session_init();
},
-
- /**
- * Called when a rpc call fail due to an invalid session.
- * By default, it's a noop
- */
- on_session_invalid: function(retry_callback) {
- },
-
/**
* Executes an RPC call, registering the provided callbacks.
*
return deferred;
});
},
-
- is_valid: function() {
+ session_is_valid: function() {
return !!this.uid;
},
-
/**
* The session is validated either by login or by restoration of a previous session
*/
window.location.reload();
},
/**
+ * Called when a rpc call fail due to an invalid session.
+ * By default, it's a noop
+ */
+ on_session_invalid: function(retry_callback) {
+ },
+ /**
* Fetches a cookie stored by an openerp session
*
* @private