summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-09-23 05:54:41 +0200
committerByron Jones <glob@mozilla.com>2015-09-23 05:54:41 +0200
commit043c7523acd6af5288191b15f746fc360b73ab40 (patch)
tree536980970ca7ae13ce29d4cf9e9f69fb0669a972 /js
parent2e425408eeb1065eacb4bcded2cc88d05a689e1c (diff)
downloadbugzilla-043c7523acd6af5288191b15f746fc360b73ab40.tar.gz
bugzilla-043c7523acd6af5288191b15f746fc360b73ab40.tar.xz
Bug 1199087 - extend 2fa protection beyond login
Diffstat (limited to 'js')
-rw-r--r--js/account.js106
1 files changed, 57 insertions, 49 deletions
diff --git a/js/account.js b/js/account.js
index 0525045b1..12a6c7a10 100644
--- a/js/account.js
+++ b/js/account.js
@@ -52,56 +52,43 @@ $(function() {
// mfa
- $('#mfa-enable')
+ $('#mfa-select-totp')
.click(function(event) {
event.preventDefault();
- $('#mfa-enable-container').show();
- $(this).hide();
- });
-
- $('#mfa')
- .change(function(event) {
- var mfa = $(this).val();
+ $('#mfa').val('TOTP');
- $('.mfa-provider').hide();
+ $('#mfa-select').hide();
$('#update').attr('disabled', true);
- if (mfa === '') {
- $('#mfa-confirm').hide();
- }
- else {
- $('#mfa-confirm').show();
- $('.mfa-api-blurb').show();
- if (mfa === 'TOTP') {
- $('#mfa-enable-totp').show();
- $('#mfa-totp-throbber').show();
- $('#mfa-totp-issued').hide();
- var url = 'rest/user/mfa/totp/enroll' +
- '?Bugzilla_api_token=' + encodeURIComponent(BUGZILLA.api_token);
- $.ajax({
- "url": url,
- "contentType": "application/json",
- "processData": false
- })
- .done(function(data) {
- $('#mfa-totp-throbber').hide();
- var iframe = $('#mfa-enable-totp-frame').contents();
- iframe.find('#qr').attr('src', 'data:image/png;base64,' + data.png);
- iframe.find('#secret').text(data.secret32);
- $('#mfa-totp-issued').show();
- $('#mfa-password').focus();
- $('#update').attr('disabled', false);
- })
- .error(function(data) {
- $('#mfa-totp-throbber').hide();
- if (data.statusText === 'abort')
- return;
- var message = data.responseJSON ? data.responseJSON.message : 'Unexpected Error';
- console.log(message);
- });
- }
- }
- })
- .change();
+ $('#mfa-confirm').show();
+ $('.mfa-api-blurb').show();
+ $('#mfa-enable-totp').show();
+ $('#mfa-totp-throbber').show();
+ $('#mfa-totp-issued').hide();
+
+ var url = 'rest/user/mfa/totp/enroll' +
+ '?Bugzilla_api_token=' + encodeURIComponent(BUGZILLA.api_token);
+ $.ajax({
+ "url": url,
+ "contentType": "application/json",
+ "processData": false
+ })
+ .done(function(data) {
+ $('#mfa-totp-throbber').hide();
+ var iframe = $('#mfa-enable-totp-frame').contents();
+ iframe.find('#qr').attr('src', 'data:image/png;base64,' + data.png);
+ iframe.find('#secret').text(data.secret32);
+ $('#mfa-totp-issued').show();
+ $('#mfa-password').focus();
+ $('#update').attr('disabled', false);
+ })
+ .error(function(data) {
+ $('#mfa-totp-throbber').hide();
+ if (data.statusText === 'abort')
+ return;
+ var message = data.responseJSON ? data.responseJSON.message : 'Unexpected Error';
+ console.log(message);
+ });
+ });
$('#mfa-disable')
.click(function(event) {
@@ -111,6 +98,7 @@ $(function() {
$('.mfa-api-blurb').hide();
$('#mfa-password').focus();
$('#update').attr('disabled', false);
+ $('.mfa-protected').hide();
$(this).hide();
});
@@ -132,8 +120,28 @@ $(function() {
if ($('#mfa-action').length) {
$('#update').attr('disabled', true);
- $(window).on('pageshow', function() {
- $('#mfa').val('').change();
- });
}
+
+ // api-key
+
+ $('#apikey-toggle-revoked')
+ .click(function(event) {
+ event.preventDefault();
+ $('.apikey_revoked.bz_tui_hidden').removeClass('bz_tui_hidden');
+ if ($('.apikey_revoked').is(':visible')) {
+ $('.apikey_revoked').hide();
+ $(this).text('Show Revoked Keys');
+ }
+ else {
+ $('.apikey_revoked').show();
+ $(this).text('Hide Revoked Keys');
+ }
+ });
+
+ $('#new_key')
+ .change(function(event) {
+ if ($(this).is(':checked')) {
+ $('#new_description').focus();
+ }
+ });
});