[IMP] anonymous: do login from js
authorChristophe Simonis <chs@openerp.com>
Wed, 23 May 2012 16:37:58 +0000 (18:37 +0200)
committerChristophe Simonis <chs@openerp.com>
Wed, 23 May 2012 16:37:58 +0000 (18:37 +0200)
bzr revid: chs@openerp.com-20120523163758-jc2vzpoe03lw4wvz

addons/anonymous/static/src/js/anonymous.js

index 32350a6..e73bb3f 100644 (file)
@@ -1,4 +1,21 @@
 openerp.anonymous = function(instance) {
     // TODO change User menu
 
+    instance.web.WebClient.include({
+        show_login: function() {
+            var self = this, _super = this._super;
+            this.login.load_db_list().then(function() {
+                var dblist = self.login._db_list;
+                if (dblist && dblist.length === 1) {
+                    // XXX get login/pass from server (via a rpc call) ?
+                    self.login.do_login(dblist[0], 'anonymous', 'anonymous').fail(function() {
+                        _super.apply(self, []);
+                    });
+                } else {
+                    _super.apply(self, []);
+                }
+            });
+        },
+    });
+
 };