summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2013-01-11 07:35:12 +0100
committerByron Jones <bjones@mozilla.com>2013-01-11 07:35:12 +0100
commit67550b5d193488738e6d5e437cd8ac95f94c3495 (patch)
tree448f5b38646bbc2b1caa3ffc18e27ee2629be9bf
parent4501ee3b1fd05a396dbe3cf99dae63b9fcfee306 (diff)
downloadbugzilla-67550b5d193488738e6d5e437cd8ac95f94c3495.tar.gz
bugzilla-67550b5d193488738e6d5e437cd8ac95f94c3495.tar.xz
Bug 743927: BrowserID is included twice on each page
-rw-r--r--extensions/BrowserID/template/en/default/hook/account/auth/login-additional_methods.html.tmpl46
-rw-r--r--extensions/BrowserID/template/en/default/hook/account/auth/login-small-additional_methods.html.tmpl58
-rw-r--r--extensions/BrowserID/template/en/default/hook/global/header-additional_header.html.tmpl61
3 files changed, 62 insertions, 103 deletions
diff --git a/extensions/BrowserID/template/en/default/hook/account/auth/login-additional_methods.html.tmpl b/extensions/BrowserID/template/en/default/hook/account/auth/login-additional_methods.html.tmpl
index 57f7da8ce..c79e1204e 100644
--- a/extensions/BrowserID/template/en/default/hook/account/auth/login-additional_methods.html.tmpl
+++ b/extensions/BrowserID/template/en/default/hook/account/auth/login-additional_methods.html.tmpl
@@ -1,51 +1,5 @@
[% IF Param('user_info_class').split(',').contains('BrowserID')
&& Param('browserid_includejs_url') %]
-
-[% USE Bugzilla %]
-[% cgi = Bugzilla.cgi %]
-
-<script src="[% Param('browserid_includejs_url') %]" type="text/javascript"></script>
-
-<script type="text/javascript">
-function createHidden(name, value, form) {
- var field = document.createElement('input');
- field.type = 'hidden';
- field.name = name;
- field.value = value;;
- form.appendChild(field);
-}
-
-function browserid_sign_in() {
- navigator.id.getVerifiedEmail(function(assertion) {
- if (assertion) {
- // This code will be invoked once the user has successfully
- // selected an email address they control to sign in with.
- var form = document.createElement('form');
- form.action = '[% target FILTER js %]';
- form.method = 'POST';
- form.style.display = 'none';
-
- createHidden('token', '[% issue_hash_token(['login']) FILTER js %]', form);
- createHidden('Bugzilla_remember', 'on', form);
- createHidden('browserid_assertion', assertion, form);
-
- [% FOREACH field = cgi.param() %]
- [% NEXT IF field.search("^(Bugzilla_(login|password|restrictlogin)|token|browserid_assertion)$") %]
- [% FOREACH mvalue = cgi.param(field).slice(0) %]
- createHidden('[% field FILTER js %]',
- '[% mvalue FILTER html_linebreak FILTER js %]',
- form);
- [% END %]
- [% END %]
-
- document.body.appendChild(form);
- form.submit();
- return true;
- }
- });
-}
-</script>
-
<p>
Or, log in with BrowserID:
<img src="extensions/BrowserID/web/sign_in_orange.png" onclick="browserid_sign_in()">
diff --git a/extensions/BrowserID/template/en/default/hook/account/auth/login-small-additional_methods.html.tmpl b/extensions/BrowserID/template/en/default/hook/account/auth/login-small-additional_methods.html.tmpl
index b1c186493..2c2f98205 100644
--- a/extensions/BrowserID/template/en/default/hook/account/auth/login-small-additional_methods.html.tmpl
+++ b/extensions/BrowserID/template/en/default/hook/account/auth/login-small-additional_methods.html.tmpl
@@ -1,60 +1,4 @@
[% IF Param('user_info_class').split(',').contains('BrowserID')
&& Param('browserid_includejs_url') %]
-<script src="[% Param('browserid_includejs_url') %]" type="text/javascript"></script>
-
-[%# Note this code is a tiny bit different from the other copy; the name of
- # the variable containing the login url is 'login_target' rather than
- # 'target' #%]
-
-<script type="text/javascript">
-function createHidden(name, value, form) {
- var field = document.createElement('input');
- field.type = 'hidden';
- field.name = name;
- field.value = value;;
- form.appendChild(field);
-}
-
-function browserid_sign_in() {
- navigator.id.getVerifiedEmail(function(assertion) {
- if (assertion) {
- // This code will be invoked once the user has successfully
- // selected an email address they control to sign in with.
- var form = document.createElement('form');
- form.action = '[% login_target FILTER js %]';
- form.method = 'POST';
- form.style.display = 'none';
-
- createHidden('token', '[% issue_hash_token(['login']) FILTER js %]', form);
- createHidden('Bugzilla_remember', 'on', form);
- createHidden('browserid_assertion', assertion, form);
-
- [% FOREACH field = cgi.param() %]
- [% NEXT IF field.search("^(Bugzilla_(login|password|restrictlogin)|token|browserid_assertion)$") %]
- [% FOREACH mvalue = cgi.param(field).slice(0) %]
- createHidden('[% field FILTER js %]',
- '[% mvalue FILTER html_linebreak FILTER js %]',
- form);
- [% END %]
- [% END %]
-
- document.body.appendChild(form);
- form.submit();
- return true;
- }
- });
-}
-YAHOO.util.Event.addListener('login_link[% qs_suffix FILTER js %]','click', function () {
- var login_link = YAHOO.util.Dom.get('browserid_mini_login[% qs_suffix FILTER js %]');
- YAHOO.util.Dom.removeClass(login_link, 'bz_default_hidden');
-});
-YAHOO.util.Event.addListener('hide_mini_login[% qs_suffix FILTER js %]','click', function () {
- var login_link = YAHOO.util.Dom.get('browserid_mini_login[% qs_suffix FILTER js %]');
- YAHOO.util.Dom.addClass(login_link, 'bz_default_hidden');
-});
-</script>
-
-<span id="browserid_mini_login[% qs_suffix FILTER html %]" class="bz_default_hidden">
- <img src="extensions/BrowserID/web/sign_in_orange.png" onclick="browserid_sign_in()" style="margin-bottom: -8px"> or
-</span>
+<img src="extensions/BrowserID/web/sign_in_orange.png" onclick="browserid_sign_in()" style="margin-bottom: -8px"> or
[% END %]
diff --git a/extensions/BrowserID/template/en/default/hook/global/header-additional_header.html.tmpl b/extensions/BrowserID/template/en/default/hook/global/header-additional_header.html.tmpl
new file mode 100644
index 000000000..2292edf7f
--- /dev/null
+++ b/extensions/BrowserID/template/en/default/hook/global/header-additional_header.html.tmpl
@@ -0,0 +1,61 @@
+[%# This Source Code Form is subject to the terms of the Mozilla Public
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ #
+ # This Source Code Form is "Incompatible With Secondary Licenses", as
+ # defined by the Mozilla Public License, v. 2.0.
+ #%]
+
+[% RETURN IF user.login
+ || !Param('browserid_includejs_url')
+ || !Param('user_info_class').split(',').contains('BrowserID') %]
+
+[% USE Bugzilla %]
+[% cgi = Bugzilla.cgi %]
+
+[% login_target = cgi.url("-relative" => 1, "-query" => 1) %]
+[% IF !login_target OR login_target.match("^token.cgi") %]
+ [% login_target = "index.cgi" %]
+[% END %]
+
+[% login_target = urlbase _ login_target %]
+
+<script src="[% Param('browserid_includejs_url') %]" type="text/javascript"></script>
+
+<script type="text/javascript">
+function createHidden(name, value, form) {
+ var field = document.createElement('input');
+ field.type = 'hidden';
+ field.name = name;
+ field.value = value;;
+ form.appendChild(field);
+}
+
+function browserid_sign_in() {
+ navigator.id.get(function(assertion) {
+ if (assertion) {
+ // This code will be invoked once the user has successfully
+ // selected an email address they control to sign in with.
+ var form = document.createElement('form');
+ form.action = '[% login_target FILTER js %]';
+ form.method = 'POST';
+ form.style.display = 'none';
+
+ createHidden('token', '[% issue_hash_token(['login']) FILTER js %]', form);
+ createHidden('Bugzilla_remember', 'on', form);
+ createHidden('browserid_assertion', assertion, form);
+
+ [% FOREACH field = cgi.param() %]
+ [% NEXT IF field.search("^(Bugzilla_(login|password|restrictlogin)|token|browserid_assertion)$") %]
+ [% FOREACH mvalue = cgi.param(field).slice(0) %]
+ createHidden('[% field FILTER js %]', '[% mvalue FILTER html_linebreak FILTER js %]', form);
+ [% END %]
+ [% END %]
+
+ document.body.appendChild(form);
+ form.submit();
+ return true;
+ }
+ });
+}
+</script>