From d028d22992917a3f898db127828ffc9e42af7246 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Fri, 30 Sep 2011 15:28:58 +0200 Subject: [ADD] auth_openid module bzr revid: chs@openerp.com-20110930132858-jsxqo21l7pn172av --- addons/auth_openid/static/src/css/openid.css | 64 ++++++++++ addons/auth_openid/static/src/img/aol.png | Bin 0 -> 2843 bytes addons/auth_openid/static/src/img/claimid.png | Bin 0 -> 1315 bytes addons/auth_openid/static/src/img/google.png | Bin 0 -> 2061 bytes addons/auth_openid/static/src/img/googleapps.gif | Bin 0 -> 4607 bytes addons/auth_openid/static/src/img/googlefav.png | Bin 0 -> 940 bytes addons/auth_openid/static/src/img/launchpad.gif | Bin 0 -> 6208 bytes addons/auth_openid/static/src/img/launchpad.png | Bin 0 -> 419 bytes addons/auth_openid/static/src/img/login-bg.gif | Bin 0 -> 328 bytes addons/auth_openid/static/src/img/marketplace.gif | Bin 0 -> 1065 bytes addons/auth_openid/static/src/img/myopenid.png | Bin 0 -> 320 bytes addons/auth_openid/static/src/img/openid.png | Bin 0 -> 1120 bytes addons/auth_openid/static/src/img/openid_16.png | Bin 0 -> 671 bytes .../auth_openid/static/src/img/textfield_key.png | Bin 0 -> 455 bytes addons/auth_openid/static/src/img/verisign.png | Bin 0 -> 520 bytes addons/auth_openid/static/src/img/yahoo.png | Bin 0 -> 2302 bytes addons/auth_openid/static/src/js/auth_openid.js | 135 +++++++++++++++++++++ addons/auth_openid/static/src/xml/auth_openid.xml | 45 +++++++ 18 files changed, 244 insertions(+) create mode 100644 addons/auth_openid/static/src/css/openid.css create mode 100644 addons/auth_openid/static/src/img/aol.png create mode 100644 addons/auth_openid/static/src/img/claimid.png create mode 100644 addons/auth_openid/static/src/img/google.png create mode 100644 addons/auth_openid/static/src/img/googleapps.gif create mode 100644 addons/auth_openid/static/src/img/googlefav.png create mode 100644 addons/auth_openid/static/src/img/launchpad.gif create mode 100644 addons/auth_openid/static/src/img/launchpad.png create mode 100644 addons/auth_openid/static/src/img/login-bg.gif create mode 100644 addons/auth_openid/static/src/img/marketplace.gif create mode 100644 addons/auth_openid/static/src/img/myopenid.png create mode 100644 addons/auth_openid/static/src/img/openid.png create mode 100644 addons/auth_openid/static/src/img/openid_16.png create mode 100644 addons/auth_openid/static/src/img/textfield_key.png create mode 100644 addons/auth_openid/static/src/img/verisign.png create mode 100644 addons/auth_openid/static/src/img/yahoo.png create mode 100644 addons/auth_openid/static/src/js/auth_openid.js create mode 100644 addons/auth_openid/static/src/xml/auth_openid.xml (limited to 'addons/auth_openid/static/src') diff --git a/addons/auth_openid/static/src/css/openid.css b/addons/auth_openid/static/src/css/openid.css new file mode 100644 index 00000000000..8763ec31685 --- /dev/null +++ b/addons/auth_openid/static/src/css/openid.css @@ -0,0 +1,64 @@ +input[name='openid_url'] { + background: #fff url(../img/login-bg.gif) no-repeat 1px; + padding-left: 20px; +} + +.auth_choice { + position: static; + 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; + float: right; +} + +.openid_providers li { + display: block; + float: left; + margin: 0 1px 3px 2px; +} + +.openid_providers a { + display: block; + width: 24px; + height: 24px; + border: 1px solid #ddd; + background: #fff url(../img/openid_16.png) no-repeat 50%; + text-indent: -9999px; + overflow: hidden; + text-align: left; +} + +.openid_providers a.selected { + border-color: #9A0404; +} + +.openid_providers a[title="Password"] { background-image: url(../img/textfield_key.png); } +.openid_providers a[title="AOL"] { background-image: url(../img/aol.png); } +.openid_providers a[title="ClaimID"] { background-image: url(../img/claimid.png); } +.openid_providers a[title="Google"] { background-image: url(../img/googlefav.png); } +.openid_providers a[title="Google Apps"] { background-image: url(../img/marketplace.gif); } +.openid_providers a[title="MyOpenID"] { background-image: url(../img/myopenid.png); } +.openid_providers a[title="VeriSign"] { background-image: url(../img/verisign.png); } +.openid_providers a[title="Yahoo!"] { background-image: url(../img/yahoo.png); } +.openid_providers a[title="Launchpad"] { background-image: url(../img/launchpad.png); } + + +tr.auth_choice.selected { + display: table-row; +} diff --git a/addons/auth_openid/static/src/img/aol.png b/addons/auth_openid/static/src/img/aol.png new file mode 100644 index 00000000000..93584e56749 Binary files /dev/null and b/addons/auth_openid/static/src/img/aol.png differ diff --git a/addons/auth_openid/static/src/img/claimid.png b/addons/auth_openid/static/src/img/claimid.png new file mode 100644 index 00000000000..41be7fc8f9e Binary files /dev/null and b/addons/auth_openid/static/src/img/claimid.png differ diff --git a/addons/auth_openid/static/src/img/google.png b/addons/auth_openid/static/src/img/google.png new file mode 100644 index 00000000000..d8b8b2a7abb Binary files /dev/null and b/addons/auth_openid/static/src/img/google.png differ diff --git a/addons/auth_openid/static/src/img/googleapps.gif b/addons/auth_openid/static/src/img/googleapps.gif new file mode 100644 index 00000000000..f86bc8956d2 Binary files /dev/null and b/addons/auth_openid/static/src/img/googleapps.gif differ diff --git a/addons/auth_openid/static/src/img/googlefav.png b/addons/auth_openid/static/src/img/googlefav.png new file mode 100644 index 00000000000..1604ac0baa5 Binary files /dev/null and b/addons/auth_openid/static/src/img/googlefav.png differ diff --git a/addons/auth_openid/static/src/img/launchpad.gif b/addons/auth_openid/static/src/img/launchpad.gif new file mode 100644 index 00000000000..48e7ba4f5b0 Binary files /dev/null and b/addons/auth_openid/static/src/img/launchpad.gif differ diff --git a/addons/auth_openid/static/src/img/launchpad.png b/addons/auth_openid/static/src/img/launchpad.png new file mode 100644 index 00000000000..7db6e67f8b5 Binary files /dev/null and b/addons/auth_openid/static/src/img/launchpad.png differ diff --git a/addons/auth_openid/static/src/img/login-bg.gif b/addons/auth_openid/static/src/img/login-bg.gif new file mode 100644 index 00000000000..e2d8377db02 Binary files /dev/null and b/addons/auth_openid/static/src/img/login-bg.gif differ diff --git a/addons/auth_openid/static/src/img/marketplace.gif b/addons/auth_openid/static/src/img/marketplace.gif new file mode 100644 index 00000000000..a3e4d2cd606 Binary files /dev/null and b/addons/auth_openid/static/src/img/marketplace.gif differ diff --git a/addons/auth_openid/static/src/img/myopenid.png b/addons/auth_openid/static/src/img/myopenid.png new file mode 100644 index 00000000000..d00ca76543b Binary files /dev/null and b/addons/auth_openid/static/src/img/myopenid.png differ diff --git a/addons/auth_openid/static/src/img/openid.png b/addons/auth_openid/static/src/img/openid.png new file mode 100644 index 00000000000..280ee6ce3b7 Binary files /dev/null and b/addons/auth_openid/static/src/img/openid.png differ diff --git a/addons/auth_openid/static/src/img/openid_16.png b/addons/auth_openid/static/src/img/openid_16.png new file mode 100644 index 00000000000..eadf8e8577f Binary files /dev/null and b/addons/auth_openid/static/src/img/openid_16.png differ diff --git a/addons/auth_openid/static/src/img/textfield_key.png b/addons/auth_openid/static/src/img/textfield_key.png new file mode 100644 index 00000000000..a9d5e4f8cc7 Binary files /dev/null and b/addons/auth_openid/static/src/img/textfield_key.png differ diff --git a/addons/auth_openid/static/src/img/verisign.png b/addons/auth_openid/static/src/img/verisign.png new file mode 100644 index 00000000000..fe890ca7aeb Binary files /dev/null and b/addons/auth_openid/static/src/img/verisign.png differ diff --git a/addons/auth_openid/static/src/img/yahoo.png b/addons/auth_openid/static/src/img/yahoo.png new file mode 100644 index 00000000000..5fbf752d9b5 Binary files /dev/null and b/addons/auth_openid/static/src/img/yahoo.png differ diff --git a/addons/auth_openid/static/src/js/auth_openid.js b/addons/auth_openid/static/src/js/auth_openid.js new file mode 100644 index 00000000000..7399e1fb371 --- /dev/null +++ b/addons/auth_openid/static/src/js/auth_openid.js @@ -0,0 +1,135 @@ + +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.$openid_selected_button = $(); + this.$openid_selected_input = $(); + this.$openid_selected_provider = null; + + + var openIdProvider = null; + if (this.has_local_storage && this.remember_creditentials) { + openIdProvider = localStorage.getItem('openid-provider'); + } + + if (openIdProvider) { + $openid_selected_provider = openIdProvider; + this.do_openid_select('a[href="#' + openIdProvider + '"]', openIdProvider, true); + + if (this.has_local_storage && this.remember_creditentials) { + this.$openid_selected_input.find('input').val(localStorage.getItem('openid-login')); + } + } + else { + this.do_openid_select('a[data-url=""]', 'login,password', true); + } + + this.$element.find('a[data-url]').click(function (event) { + event.preventDefault(); + var selected_oidh = $(this).attr('href').substr(1); + if (selected_oidh != self.$openid_selected_provider) { + self.do_openid_select(this, selected_oidh); + } + }); + + }, + + + do_openid_select: function (button, provider, noautosubmit) { + var self = this; + + 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(','); + self.$openid_selected_input = self.$element.find(input).addClass('selected'); + + self.$openid_selected_input.find('input:first').focus(); + self.$openid_selected_provider = (self.$openid_selected_button.attr('href') || '').substr(1); + + if (self.has_local_storage && self.remember_creditentials) { + localStorage.setItem('openid-provider', self.$openid_selected_provider); + } + + if (!noautosubmit && self.$openid_selected_input.length == 0) { + self.$element.find('form').submit(); + } + + }, + + on_login_invalid: function() { + var self = this; + var fragment = jQuery.deparam.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); + } + if (result.status === 'setup_needed' && result.message) { + window.location.replace(result.message); + } + }); + } + return this._super(); + }, + + on_submit: function(ev) { + + var dataurl = this.$openid_selected_button.attr('data-url'); + + if(!dataurl) { + // login-password submitted + this._super(ev); + } else { + ev.preventDefault(); + + var id = this.$openid_selected_input.find('input').val(); + if (this.has_local_storage && this.remember_creditentials) { + localStorage.setItem('openid-login', id); + } + + var db = this.$element.find("form [name=db]").val(); + var openid_url = dataurl.replace('{id}', id); + + this.do_openid_login(db, openid_url); + + } + }, + + do_openid_login: function(db, openid_url) { + 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(); + return; + } + if (result.session_id) { + self.session.session_id = result.session_id; + self.session.session_save(); + } + if (result.action === 'post') { + document.open(); + document.write(result.value); + document.close(); + } else if (result.action === 'redirect') { + window.location.replace(result.value); + } else { + // XXX display error ? + } + + }); + }, + + +}); + + +}; diff --git a/addons/auth_openid/static/src/xml/auth_openid.xml b/addons/auth_openid/static/src/xml/auth_openid.xml new file mode 100644 index 00000000000..6fbab72e831 --- /dev/null +++ b/addons/auth_openid/static/src/xml/auth_openid.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + //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'); + this.each(function() { + var $i = $(this); + $i.attr('data-provider', $i.find('input').attr('name')); + }); + + + + -- cgit v1.2.3