summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Simonis <chs@openerp.com>2012-01-12 13:54:16 +0100
committerChristophe Simonis <chs@openerp.com>2012-01-12 13:54:16 +0100
commit137310ed4a4e0fed5a20f1520662f2b3a8bd7b4f (patch)
treeaba5c544a9b700f554d140f709e2855dd62d24fe
parent5446d01ba1ee51659460cbf47945643029e5f011 (diff)
[FIX] adapt auth_openid to new login page
bzr revid: chs@openerp.com-20120112125416-uixisb5sks604ejg
-rw-r--r--addons/auth_openid/__openerp__.py5
-rw-r--r--addons/auth_openid/controllers/main.py4
-rw-r--r--addons/auth_openid/static/src/css/openid.css22
-rw-r--r--addons/auth_openid/static/src/js/auth_openid.js30
-rw-r--r--addons/auth_openid/static/src/xml/auth_openid.xml33
5 files changed, 60 insertions, 34 deletions
diff --git a/addons/auth_openid/__openerp__.py b/addons/auth_openid/__openerp__.py
index 6fa802b94e3..178996bc33a 100644
--- a/addons/auth_openid/__openerp__.py
+++ b/addons/auth_openid/__openerp__.py
@@ -2,7 +2,7 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
-# Copyright (C) 2010-2011 OpenERP s.a. (<http://openerp.com>).
+# Copyright (C) 2010-2012 OpenERP s.a. (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -38,6 +38,9 @@
'css': [
'static/src/css/openid.css',
],
+ 'qweb': [
+ 'static/src/xml/auth_openid.xml',
+ ],
'external_dependencies': {
'python' : ['openid'],
},
diff --git a/addons/auth_openid/controllers/main.py b/addons/auth_openid/controllers/main.py
index 0c1274ba05a..c95189b7736 100644
--- a/addons/auth_openid/controllers/main.py
+++ b/addons/auth_openid/controllers/main.py
@@ -2,7 +2,7 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
-# Copyright (C) 2010-2011 OpenERP s.a. (<http://openerp.com>).
+# Copyright (C) 2010-2012 OpenERP s.a. (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -216,7 +216,7 @@ class OpenIDController(openerpweb.Controller):
fragment = '#loginerror' if not user_id else ''
- return werkzeug.utils.redirect('/web/webclient/home?debug=1'+fragment)
+ return werkzeug.utils.redirect('/'+fragment)
@openerpweb.jsonrequest
def status(self, req):
diff --git a/addons/auth_openid/static/src/css/openid.css b/addons/auth_openid/static/src/css/openid.css
index 8763ec31685..ab01ffd2f60 100644
--- a/addons/auth_openid/static/src/css/openid.css
+++ b/addons/auth_openid/static/src/css/openid.css
@@ -1,4 +1,9 @@
-input[name='openid_url'] {
+.login .pane {
+ width: 260px;
+ height: 175px;
+}
+
+.login .pane input[name='openid_url'] {
background: #fff url(../img/login-bg.gif) no-repeat 1px;
padding-left: 20px;
}
@@ -8,19 +13,6 @@ input[name='openid_url'] {
display: none;
}
-.openerp .login .oe_forms .oe_box2 td input[name="db"], .oe_forms .oe_box2 td select[name="db"] {
- width: 50%;
- float: left;
- margin-top: 15px;
-}
-
-.openerp .login .oe_login_right_pane {
- margin-left: 525px;
-}
-.openerp .login form {
- width: 475px;
-}
-
.openid_providers {
padding: 0;
list-style: none;
@@ -59,6 +51,6 @@ input[name='openid_url'] {
.openid_providers a[title="Launchpad"] { background-image: url(../img/launchpad.png); }
-tr.auth_choice.selected {
+li.auth_choice.selected {
display: table-row;
}
diff --git a/addons/auth_openid/static/src/js/auth_openid.js b/addons/auth_openid/static/src/js/auth_openid.js
index bc067d8824d..fd6ec01cc0f 100644
--- a/addons/auth_openid/static/src/js/auth_openid.js
+++ b/addons/auth_openid/static/src/js/auth_openid.js
@@ -2,13 +2,14 @@
openerp.auth_openid = function(instance) {
var QWeb = instance.web.qweb;
-QWeb.add_template('/auth_openid/static/src/xml/auth_openid.xml');
instance.web.Login = instance.web.Login.extend({
start: function() {
this._super.apply(this, arguments);
var self = this;
+ this._default_error_message = this.$element.find('.login_error_message').text();
+
this.$openid_selected_button = $();
this.$openid_selected_input = $();
this.$openid_selected_provider = null;
@@ -39,6 +40,8 @@ instance.web.Login = instance.web.Login.extend({
}
});
+ this._check_fragment();
+
},
@@ -48,7 +51,7 @@ instance.web.Login = instance.web.Login.extend({
self.$openid_selected_button.add(self.$openid_selected_input).removeClass('selected');
self.$openid_selected_button = self.$element.find(button).addClass('selected');
- var input = _(provider.split(',')).map(function(p) { return 'tr[data-provider="'+p+'"]'; }).join(',');
+ var input = _(provider.split(',')).map(function(p) { return 'li[data-provider="'+p+'"]'; }).join(',');
self.$openid_selected_input = self.$element.find(input).addClass('selected');
self.$openid_selected_input.find('input:first').focus();
@@ -64,20 +67,20 @@ instance.web.Login = instance.web.Login.extend({
},
- on_login_invalid: function() {
+ _check_fragment: function() {
var self = this;
var fragment = jQuery.deparam.fragment();
- if (fragment.loginerror != undefined) {
+ console.log(fragment);
+ if (fragment.loginerror !== undefined) {
this.rpc('/auth_openid/login/status', {}, function(result) {
if (_.contains(['success', 'failure'], result.status) && result.message) {
- self.notification.warn('Invalid OpenID Login', result.message);
+ self.do_warn('Invalid OpenID Login', result.message);
}
if (result.status === 'setup_needed' && result.message) {
window.location.replace(result.message);
}
});
}
- return this._super();
},
on_submit: function(ev) {
@@ -86,6 +89,7 @@ instance.web.Login = instance.web.Login.extend({
if(!dataurl) {
// login-password submitted
+ this.reset_error_message();
this._super(ev);
} else {
ev.preventDefault();
@@ -107,13 +111,11 @@ instance.web.Login = instance.web.Login.extend({
var self = this;
this.rpc('/auth_openid/login/verify', {'db': db, 'url': openid_url}, function(result) {
if (result.error) {
- self.notification.warn(result.title, result.error);
- self.on_login_invalid();
+ self.do_warn(result.title, result.error);
return;
}
if (result.session_id) {
- self.session.session_id = result.session_id;
- self.session.session_save();
+ self.session.set_cookie('session_id', result.session_id);
}
if (result.action === 'post') {
document.open();
@@ -128,6 +130,14 @@ instance.web.Login = instance.web.Login.extend({
});
},
+ do_warn: function(title, msg) {
+ //console.warn(title, msg);
+ this.$element.find('.login_error_message').text(msg).show();
+ },
+
+ reset_error_message: function() {
+ this.$element.find('.login_error_message').text(this._default_error_message);
+ }
});
diff --git a/addons/auth_openid/static/src/xml/auth_openid.xml b/addons/auth_openid/static/src/xml/auth_openid.xml
index 6fbab72e831..34894555668 100644
--- a/addons/auth_openid/static/src/xml/auth_openid.xml
+++ b/addons/auth_openid/static/src/xml/auth_openid.xml
@@ -3,7 +3,7 @@
<templates id="template" xml:space="preserve">
<t t-extend="Login">
- <t t-jquery=".oe_box2 tr:first td:nth-child(2)" t-operation="append">
+ <t t-jquery=".login .pane div#logo" t-operation="after">
<ul class="openid_providers">
<li><a href="#login,password" title="Password" data-url="" id="btn_password">Password</a></li>
<li><a href="#google" title="Google" data-url="https://www.google.com/accounts/o8/id">Google</a></li>
@@ -30,14 +30,35 @@
</tr>
</t>
</t>
+ <t t-extend="Login">
+ <t t-jquery=".login .pane form ul li:nth-child(4)" t-operation="after">
+ <li>
+ Google Apps Domain
+ </li>
+ <li>
+ <input type="text" name="googleapps" />
+ </li>
+ <li>
+ Username
+ </li>
+ <li>
+ <input type="text" name="launchpad" />
+ </li>
+ <li>
+ OpenID URL
+ </li>
+ <li>
+ <input type="text" name="openid_url" />
+ </li>
+ </t>
+ </t>
<t t-extend="Login">
- <t t-jquery=".oe_box2 tr:has(input[name!='db'])">
- //this.addClass('auth_choice'); // XXX for some reason, not all tr tags are HTMLElement's and thus, jQuery decide to not change the class...
- this.attr('class', 'auth_choice');
+ <t t-jquery=".login .pane form ul li:has(input)">
this.each(function() {
- var $i = $(this);
- $i.attr('data-provider', $i.find('input').attr('name'));
+ var $i = $(this),
+ dp = $i.find('input').attr('name');
+ $i.add($i.prev()).attr('class', 'auth_choice').attr('data-provider', dp);
});
</t>
</t>