[fix] lot of bug correction related to auto-login

bzr revid: nicolas.vanhoren@openerp.com-20110905101143-lcm2g0biekydhj2n
This commit is contained in:
niv-openerp 2011-09-05 12:11:43 +02:00
parent 43eefa0fa6
commit 8c778b887d
2 changed files with 10 additions and 8 deletions

View File

@ -518,7 +518,7 @@ openerp.web.Login = openerp.web.Widget.extend({
this.on_login_valid.add({
position: "last",
unique: true,
callback: continuation
callback: continuation || function() {}
});
},
on_logout: function() {
@ -539,13 +539,13 @@ openerp.web.Header = openerp.web.Widget.extend({
},
do_update: function () {
var self = this;
return new openerp.base.Model(self.session, "res.users")
.get_func("read")(self.session.uid, ["name", "company_id"]).pipe(function(res) {
var func = new openerp.base.Model(self.session, "res.users").get_func("read");
func(self.session.uid, ["name", "company_id"]).then(function(res) {
self.$content = $(QWeb.render("Header-content", {widget: self, user: res}));
self.$content.appendTo(self.$element);
self.$element.find(".logout").click(self.on_logout);
self.$element.find("a.preferences").click(self.on_preferences);
return self.shortcut_load();
self.shortcut_load();
});
},
do_reset: function() {

View File

@ -470,9 +470,8 @@ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web
self.user_context = result.context;
self.session_save();
self.on_session_valid();
if (success_callback)
success_callback();
});
return true;
}).then(success_callback);
},
session_logout: function() {
this.uid = false;
@ -488,7 +487,10 @@ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web
this.user_context = this.get_cookie("user_context");
// we should do an rpc to confirm that this session_id is valid and if it is retrieve the information about db and login
// then call on_session_valid
this.on_session_valid();
if (this.uid)
this.on_session_valid();
else
this.on_session_invalid();
},
/**
* Saves the session id and uid locally