##############################################################################
#
# 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
'css': [
'static/src/css/openid.css',
],
+ 'qweb': [
+ 'static/src/xml/auth_openid.xml',
+ ],
'external_dependencies': {
'python' : ['openid'],
},
##############################################################################
#
# 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
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):
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;
}
});
+ this._check_fragment();
+
},
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();
},
- 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) {
if(!dataurl) {
// login-password submitted
+ this.reset_error_message();
this._super(ev);
} else {
ev.preventDefault();
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();
});
},
+ 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);
+ }
});
<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>
</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>