UX: Add reset password email button when confirming password before enabling 2FA.

This commit is contained in:
Guo Xiang Tan 2018-02-23 15:32:18 +08:00
parent a94dc0c731
commit 4791b39773
3 changed files with 23 additions and 3 deletions

View File

@ -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);
},

View File

@ -91,7 +91,7 @@
{{text-field value=password
id="password"
type="password"
classNames="input-large"
classNames="input-xxlarge"
autofocus="autofocus"}}
</div>
@ -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}}
</div>
</div>
{{/if}}

View File

@ -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