diff options
Diffstat (limited to 'extensions/Persona/template/en/default/hook/global/header-additional_header.html.tmpl')
-rw-r--r-- | extensions/Persona/template/en/default/hook/global/header-additional_header.html.tmpl | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/extensions/Persona/template/en/default/hook/global/header-additional_header.html.tmpl b/extensions/Persona/template/en/default/hook/global/header-additional_header.html.tmpl new file mode 100644 index 000000000..d4cc2132e --- /dev/null +++ b/extensions/Persona/template/en/default/hook/global/header-additional_header.html.tmpl @@ -0,0 +1,65 @@ +[%# 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('persona_includejs_url') + || !Param('user_info_class').split(',').contains('Persona') %] + +[% 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('persona_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 persona_sign_in() { + navigator.id.request({ siteName: '[% terms.BugzillaTitle FILTER js %]' }); + navigator.id.watch({ + loggedInUser: [% IF user.id %]'[% user.login FILTER js %]'[% ELSE %]null[% END %], + onlogin: function(assertion) { + 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('persona_assertion', assertion, form); + + [% FOREACH field = cgi.param() %] + [% NEXT IF field.search("^(Bugzilla_(login|password|restrictlogin)|token|persona_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; + }, + onlogout: function () { + document.location = '[% urlbase FILTER none %]index.cgi?logout=1'; + return true; + } + }); +} +</script> |