summaryrefslogtreecommitdiff
path: root/addons/auth_openid/static/src
diff options
context:
space:
mode:
authorFabien Pinckaers <fp@tinyerp.com>2011-10-01 20:48:11 +0200
committerFabien Pinckaers <fp@tinyerp.com>2011-10-01 20:48:11 +0200
commit57b86a10409f08345bfb2e14d039289ae4603104 (patch)
tree957fa49ea222687ff62bc778ae6be594cd905429 /addons/auth_openid/static/src
parentac214af8d058902d443792ee41cc2e4f9721bb5d (diff)
parent84f188ce7d08d5a6d515b5d07d365ed930668ffe (diff)
merge
bzr revid: fp@tinyerp.com-20111001184811-umj7qepl2ly9jh0d
Diffstat (limited to 'addons/auth_openid/static/src')
-rw-r--r--addons/auth_openid/static/src/css/openid.css64
-rw-r--r--addons/auth_openid/static/src/img/aol.pngbin0 -> 2843 bytes
-rw-r--r--addons/auth_openid/static/src/img/claimid.pngbin0 -> 1315 bytes
-rw-r--r--addons/auth_openid/static/src/img/google.pngbin0 -> 2061 bytes
-rw-r--r--addons/auth_openid/static/src/img/googleapps.gifbin0 -> 4607 bytes
-rw-r--r--addons/auth_openid/static/src/img/googlefav.pngbin0 -> 940 bytes
-rw-r--r--addons/auth_openid/static/src/img/launchpad.gifbin0 -> 6208 bytes
-rw-r--r--addons/auth_openid/static/src/img/launchpad.pngbin0 -> 419 bytes
-rw-r--r--addons/auth_openid/static/src/img/login-bg.gifbin0 -> 328 bytes
-rw-r--r--addons/auth_openid/static/src/img/marketplace.gifbin0 -> 1065 bytes
-rw-r--r--addons/auth_openid/static/src/img/myopenid.pngbin0 -> 320 bytes
-rw-r--r--addons/auth_openid/static/src/img/openid.pngbin0 -> 1120 bytes
-rw-r--r--addons/auth_openid/static/src/img/openid_16.pngbin0 -> 671 bytes
-rw-r--r--addons/auth_openid/static/src/img/textfield_key.pngbin0 -> 455 bytes
-rw-r--r--addons/auth_openid/static/src/img/verisign.pngbin0 -> 520 bytes
-rw-r--r--addons/auth_openid/static/src/img/yahoo.pngbin0 -> 2302 bytes
-rw-r--r--addons/auth_openid/static/src/js/auth_openid.js135
-rw-r--r--addons/auth_openid/static/src/xml/auth_openid.xml45
18 files changed, 244 insertions, 0 deletions
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
--- /dev/null
+++ b/addons/auth_openid/static/src/img/aol.png
Binary files 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
--- /dev/null
+++ b/addons/auth_openid/static/src/img/claimid.png
Binary files 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
--- /dev/null
+++ b/addons/auth_openid/static/src/img/google.png
Binary files 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
--- /dev/null
+++ b/addons/auth_openid/static/src/img/googleapps.gif
Binary files 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
--- /dev/null
+++ b/addons/auth_openid/static/src/img/googlefav.png
Binary files 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
--- /dev/null
+++ b/addons/auth_openid/static/src/img/launchpad.gif
Binary files 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
--- /dev/null
+++ b/addons/auth_openid/static/src/img/launchpad.png
Binary files 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
--- /dev/null
+++ b/addons/auth_openid/static/src/img/login-bg.gif
Binary files 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
--- /dev/null
+++ b/addons/auth_openid/static/src/img/marketplace.gif
Binary files 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
--- /dev/null
+++ b/addons/auth_openid/static/src/img/myopenid.png
Binary files 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
--- /dev/null
+++ b/addons/auth_openid/static/src/img/openid.png
Binary files 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
--- /dev/null
+++ b/addons/auth_openid/static/src/img/openid_16.png
Binary files 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
--- /dev/null
+++ b/addons/auth_openid/static/src/img/textfield_key.png
Binary files 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
--- /dev/null
+++ b/addons/auth_openid/static/src/img/verisign.png
Binary files 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
--- /dev/null
+++ b/addons/auth_openid/static/src/img/yahoo.png
Binary files 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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vim:fdl=1: -->
+<templates id="template" xml:space="preserve">
+
+ <t t-extend="Login">
+ <t t-jquery=".oe_box2 tr:first td:nth-child(2)" t-operation="append">
+ <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>
+ <li><a href="#googleapps" title="Google Apps" data-url="https://www.google.com/accounts/o8/site-xrds?hd={id}">Google</a></li>
+ <li><a href="#launchpad" title="Launchpad" data-url="https://launchpad.net/~{id}">Launchpad</a></li>
+ <li><a href="#openid_url" title="OpenID" data-url="{id}">OpenID</a></li>
+ </ul>
+ </t>
+ </t>
+
+ <t t-extend="Login">
+ <t t-jquery=".oe_box2 tr:first" t-operation="after">
+ <tr>
+ <td><label for="googleapps">Google Apps Domain:</label></td>
+ <td><input type="text" name="googleapps" /></td>
+ </tr>
+ <tr>
+ <td><label for="launchpad">Username:</label></td>
+ <td><input type="text" name="launchpad" /></td>
+ </tr>
+ <tr>
+ <td><label for="openid_url">OpenID URL:</label></td>
+ <td><input type="text" name="openid_url" /></td>
+ </tr>
+ </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');
+ this.each(function() {
+ var $i = $(this);
+ $i.attr('data-provider', $i.find('input').attr('name'));
+ });
+ </t>
+ </t>
+
+</templates>