]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1400419 - Direct GitHub-auth'd users that are required to use 2FA to issue a...
authorDylan William Hardison <dylan@hardison.net>
Tue, 19 Sep 2017 15:46:25 +0000 (11:46 -0400)
committerGitHub <noreply@github.com>
Tue, 19 Sep 2017 15:46:25 +0000 (11:46 -0400)
Bugzilla.pm
js/account.js
template/en/default/account/prefs/mfa.html.tmpl

index 96eff5df2e5f1712e629da88e8ac362c52b15e94..9234243f79b8f569b628ed384580f585b881cf39 100644 (file)
@@ -407,13 +407,14 @@ sub login {
         my $grace_period = Bugzilla->params->{mfa_group_grace_period};
         my $expired      = defined $date && $date < DateTime->now;
         my $on_mfa_page  = $cgi->script_name eq '/userprefs.cgi' && $cgi->param('tab') eq 'mfa';
+        my $on_token_page = $cgi->script_name eq '/token.cgi';
 
         Bugzilla->request_cache->{mfa_warning} = 1;
         Bugzilla->request_cache->{mfa_grace_period_expired} = $expired;
         Bugzilla->request_cache->{on_mfa_page} = $on_mfa_page;
 
         if ( $grace_period == 0 || $expired) {
-            if (!$on_mfa_page) {
+            if ( !( $on_mfa_page || $on_token_page ) ) {
                 print Bugzilla->cgi->redirect("userprefs.cgi?tab=mfa");
                 exit;
             }
index c5557aa41d4a5b19d4a76e5962536b0affcea2e6..8642cadbd751d026e9e97a8faef548b13a15d3ab 100644 (file)
@@ -287,7 +287,18 @@ $(function() {
         });
 
     if ($('#mfa-action').length) {
-        $('#update').attr('disabled', true);
+        if ($("#mfa-action").data('nopassword')) {
+            $('#update')
+                .attr('disabled', false)
+                .val("Reset Password")
+                .click(function(event) {
+                    event.preventDefault();
+                    $('#forgot-form').submit();
+                });
+        }
+        else {
+            $("#update").attr('disabled', true);
+        }
     }
 
     // api-key
index 99a4b0f2aac227b92d41fe73d3499d2a347be38c..482832f630ae3698441f2e2693d6e98fc5272d4c 100644 (file)
@@ -7,6 +7,13 @@
   #%]
 
 [% SET MFA_HOWTO = "https://wiki.mozilla.org/BMO/UserGuide/Two-Factor_Authentication" %]
+[% tab_footer = BLOCK %]
+  <form action="token.cgi" method="post" id="forgot-form">
+    <input type="hidden" name="loginname" value="[% user.login FILTER html %]">
+    <input type="hidden" name="a" value="reqpw">
+    <input type="hidden" name="token" value="[% issue_hash_token(['reqpw']) FILTER html %]">
+  </form>
+[% END %]
 
 [% IF NOT Bugzilla.feature('mfa') %]
   <input type="hidden" name="mfa_action" id="mfa-action" value="">
   [% RETURN %]
 [% END %]
 [% IF user.cryptpassword == '*' %]
-  <input type="hidden" name="mfa_action" id="mfa-action" value="">
+  <input type="hidden" name="mfa_action" id="mfa-action" value="" data-nopassword="true">
+  [% IF Bugzilla.request_cache.mfa_warning %]
+    <p>
+      Your account requires Two-Factor authentication to be configured before you can use [% terms.Bugzilla %]
+    </p>
+  [% END %]
+  <p>
+    Before you can enable two-factor authentication you must set a password on your account.
+    To do this on your account please click on "Reset Password";
+    this will email you instructions to start the password reset process.
+  </p>
   <p>
-    Two-factor Authentication is not available on your account because you are
-    using an external authentication provider.
+    As part of this transition you will no longer be able to use GitHub to log in to [% terms.Bugzilla %].
   </p>
   [% RETURN %]
 [% END %]