A platform for community discussion. Free, open, simple.
UX: Add reset password email button when confirming password before enabling 2FA.
Guo Xiang Tan4791b3977362
diff --git a/app/assets/javascripts/discourse/controllers/preferences/second-factor.js.es6 b/app/assets/javascripts/discourse/controllers/preferences/second-factor.js.es6index d66ee78360f..f1d4bb0dbf8 100644--- a/app/assets/javascripts/discourse/controllers/preferences/second-factor.js.es6+++ b/app/assets/javascripts/discourse/controllers/preferences/second-factor.js.es6@@ -4,6 +4,8 @@ import { popupAjaxError } from 'discourse/lib/ajax-error';export default Ember.Controller.extend({loading: false,+ resetPasswordLoading: false,+ resetPasswordProgress: '',password: null,secondFactorImage: null,secondFactorKey: null,@@ -61,6 +63,19 @@ export default Ember.Controller.extend({.finally(() => this.set('loading', false));},+ resetPassword() {+ this.setProperties({+ resetPasswordLoading: true,+ resetPasswordProgress: ''+ });++ return this.get('model').changePassword().then(() => {+ this.set('resetPasswordProgress', I18n.t('user.change_password.success'));+ })+ .catch(popupAjaxError)+ .finally(() => this.set('resetPasswordLoading', false));+ },+showSecondFactorKey() {this.set('showSecondFactorKey', true);},diff --git a/app/assets/javascripts/discourse/templates/preferences-second-factor.hbs b/app/assets/javascripts/discourse/templates/preferences-second-factor.hbsindex 13cbbc5da92..a1b6f7ef1ac 100644--- a/app/assets/javascripts/discourse/templates/preferences-second-factor.hbs+++ b/app/assets/javascripts/discourse/templates/preferences-second-factor.hbs@@ -91,7 +91,7 @@{{text-field value=passwordid="password"type="password"- classNames="input-large"+ classNames="input-xxlarge"autofocus="autofocus"}}</div>@@ -107,7 +107,12 @@disabled=loadinglabel=submitButtonText}}- {{#if saved}}{{i18n 'saved'}}{{/if}}+ {{d-button action="resetPassword"+ class="btn"+ disabled=resetPasswordLoading+ label='user.change_password.action'}}++ {{resetPasswordProgress}}</div></div>{{/if}}diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex 2fb1c741587..bf70f73c731 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -712,7 +712,7 @@ en:title: "Two Factor Authentication"enabled_status: "Status: On"disabled_status: "Status: Off"- confirm_password_description: "Confirm your password to continue enabling Two Factor Authentication."+ confirm_password_description: "Confirm your password to continue enabling Two Factor Authentication"enable_description: |To complete Two Factor Authentication setup, scan the following QR codein one of the supported apps