From 4791b3977362de6f47ef36a82debf39bd38e9d14 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Fri, 23 Feb 2018 15:32:18 +0800 Subject: [PATCH] UX: Add reset password email button when confirming password before enabling 2FA. --- .../controllers/preferences/second-factor.js.es6 | 15 +++++++++++++++ .../templates/preferences-second-factor.hbs | 9 +++++++-- config/locales/client.en.yml | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/preferences/second-factor.js.es6 b/app/assets/javascripts/discourse/controllers/preferences/second-factor.js.es6 index 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.hbs index 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=password id="password" type="password" - classNames="input-large" + classNames="input-xxlarge" autofocus="autofocus"}} @@ -107,7 +107,12 @@ disabled=loading label=submitButtonText}} - {{#if saved}}{{i18n 'saved'}}{{/if}} + {{d-button action="resetPassword" + class="btn" + disabled=resetPasswordLoading + label='user.change_password.action'}} + + {{resetPasswordProgress}} {{/if}} diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 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 code in one of the supported apps