UX cleanup changes to 2FA flow.

This commit is contained in:
Guo Xiang Tan 2018-03-23 11:05:11 +08:00
parent 0db13f62eb
commit 7a4b70ef58
9 changed files with 50 additions and 33 deletions

View File

@ -0,0 +1,3 @@
export default Ember.Component.extend({
tagName: ''
});

View File

@ -40,9 +40,9 @@ export default Ember.Controller.extend(CanCheckEmails, PreferencesTabController,
return !this.siteSettings.enable_sso && this.siteSettings.enable_local_logins; return !this.siteSettings.enable_sso && this.siteSettings.enable_local_logins;
}, },
@computed("model.second_factor_enabled") @computed
secondFactorStatusClass(secondFactorEnabled) { showTwoFactorModalText() {
return secondFactorEnabled ? 'tip good' : 'tip bad'; return I18n.t('user.second_factor.title').toLowerCase();
}, },
actions: { actions: {

View File

@ -18,7 +18,17 @@ export default Ember.Controller.extend({
@computed('loading') @computed('loading')
submitButtonText(loading) { submitButtonText(loading) {
return loading ? 'loading' : 'submit'; return loading ? 'loading' : 'continue';
},
@computed('loading')
enableButtonText(loading) {
return loading ? 'loading' : 'enable';
},
@computed('loading')
disableButtonText(loading) {
return loading ? 'loading' : 'disable';
}, },
@computed @computed

View File

@ -0,0 +1,3 @@
{{#link-to route args}}
{{i18n 'cancel'}}
{{/link-to}}

View File

@ -15,7 +15,7 @@
{{/if}} {{/if}}
{{#if model.second_factor_enabled}} {{#if model.second_factor_enabled}}
<label class='control-label'>{{i18n 'login.second_factor_label'}}</label> <label class='control-label'>{{i18n 'user.second_factor.label'}}</label>
<div class="control-group"> <div class="control-group">
<div class="controls"> <div class="controls">
@ -32,7 +32,9 @@
{{d-button action="disableSecondFactor" {{d-button action="disableSecondFactor"
class="btn btn-primary" class="btn btn-primary"
disabled=loading disabled=loading
label=submitButtonText}} label=disableButtonText}}
{{cancel-link route="preferences.account" args= model.username}}
</div> </div>
</div> </div>
{{else}} {{else}}
@ -66,7 +68,7 @@
</div> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label input-prepend">{{i18n 'login.second_factor_label'}}</label> <label class="control-label input-prepend">{{i18n 'user.second_factor.label'}}</label>
<div class="controls"> <div class="controls">
{{second-factor-input value=secondFactorToken inputId='second-factor-token'}} {{second-factor-input value=secondFactorToken inputId='second-factor-token'}}
@ -78,7 +80,9 @@
{{d-button action="enableSecondFactor" {{d-button action="enableSecondFactor"
class="btn btn-primary" class="btn btn-primary"
disabled=loading disabled=loading
label=submitButtonText}} label=enableButtonText}}
{{cancel-link route="preferences.account" args= model.username}}
</div> </div>
</div> </div>
{{else}} {{else}}
@ -108,9 +112,12 @@
{{d-button action="resetPassword" {{d-button action="resetPassword"
class="btn" class="btn"
disabled=resetPasswordLoading disabled=resetPasswordLoading
icon="envelope"
label='user.change_password.action'}} label='user.change_password.action'}}
{{resetPasswordProgress}} {{resetPasswordProgress}}
{{cancel-link route="preferences.account" args= model.username}}
</div> </div>
</div> </div>
{{/if}} {{/if}}

View File

@ -63,27 +63,18 @@
{{i18n 'user.change_password.action'}} {{i18n 'user.change_password.action'}}
{{/if}} {{/if}}
</a> </a>
{{passwordProgress}} {{passwordProgress}}
</div> </div>
</div>
<div class="control-group pref-second-factor"> <div class="controls pref-second-factor">
<label class="control-label">{{i18n 'user.second_factor.title'}}</label> {{#if model.second_factor_enabled}}
{{i18n 'user.second_factor.disable'}}
<div class="instructions"> {{else}}
<a href {{action "showTwoFactorModal"}}>{{i18n 'user.second_factor.info_prompt'}}</a> {{i18n 'enable'}}
</div> <a href {{action "showTwoFactorModal"}}>{{showTwoFactorModalText}}</a>
{{i18n 'user.second_factor.enable'}}
<div class="controls"> {{/if}}
<b class="{{secondFactorStatusClass}}">
{{#if model.second_factor_enabled}}
{{i18n 'user.second_factor.enabled_status'}}
{{d-icon 'check'}}
{{else}}
{{i18n 'user.second_factor.disabled_status'}}
{{d-icon 'times'}}
{{/if}}
</b>
{{#if isCurrentUser}} {{#if isCurrentUser}}
{{#link-to "preferences.second-factor" class="btn btn-small btn-icon pad-left no-text"}} {{#link-to "preferences.second-factor" class="btn btn-small btn-icon pad-left no-text"}}

View File

@ -100,6 +100,10 @@
} }
} }
.pref-second-factor {
margin-top: 10px;
}
.user-invite-list { .user-invite-list {
width: 100%; width: 100%;
margin-top: 15px; margin-top: 15px;

View File

@ -970,7 +970,7 @@ class UsersController < ApplicationController
) )
render json: success_json.merge( render json: success_json.merge(
key: current_user.user_second_factor.data, key: current_user.user_second_factor.data.scan(/.{4}/).join(" "),
qr: qrcode_svg qr: qrcode_svg
) )
end end

View File

@ -313,6 +313,7 @@ en:
enable: "Enable" enable: "Enable"
disable: "Disable" disable: "Disable"
continue: "Continue"
undo: "Undo" undo: "Undo"
revert: "Revert" revert: "Revert"
failed: "Failed" failed: "Failed"
@ -727,15 +728,14 @@ en:
second_factor: second_factor:
title: "Two Factor Authentication" title: "Two Factor Authentication"
disable: "Disable Two Factor Authentication" disable: "Disable two factor authentication"
enabled_status: "Status: On" enable: "for enhanced account security"
disabled_status: "Status: Off"
confirm_password_description: "Please confirm your password to continue" confirm_password_description: "Please confirm your password to continue"
label: "Code"
enable_description: | enable_description: |
Scan this QR code in a supported app (<a href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2" target="_blank">Android</a> <a href="https://itunes.apple.com/us/app/google-authenticator/id388497605?mt=8" target="_blank">iOS</a> <a href="https://www.microsoft.com/en-us/store/p/authenticator/9wzdncrfj3rj" target='_blank'>Windows Phone</a>) and enter your authentication code. Scan this QR code in a supported app (<a href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2" target="_blank">Android</a> <a href="https://itunes.apple.com/us/app/google-authenticator/id388497605?mt=8" target="_blank">iOS</a> <a href="https://www.microsoft.com/en-us/store/p/authenticator/9wzdncrfj3rj" target='_blank'>Windows Phone</a>) and enter your authentication code.
disable_description: "Please enter the authentication code from your app:" disable_description: "Please enter the authentication code from your app:"
show_key_description: "Enter manually" show_key_description: "Enter manually"
info_prompt: "What is Two Factor Authentication?"
extended_description: | extended_description: |
Two factor authentication adds extra security to your account by requiring a one-time token in addition to your password. Tokens can be generated on <a href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2" target='_blank'>Android</a>, <a href="https://itunes.apple.com/us/app/google-authenticator/id388497605?mt=8">iOS</a>, and <a href="https://www.microsoft.com/en-us/store/p/authenticator/9wzdncrfj3rj" target='_blank'>Windows Phone</a> devices. Two factor authentication adds extra security to your account by requiring a one-time token in addition to your password. Tokens can be generated on <a href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2" target='_blank'>Android</a>, <a href="https://itunes.apple.com/us/app/google-authenticator/id388497605?mt=8">iOS</a>, and <a href="https://www.microsoft.com/en-us/store/p/authenticator/9wzdncrfj3rj" target='_blank'>Windows Phone</a> devices.
oauth_enabled_warning: "Please note that social logins will be disabled once two factor authentication has been enabled on your account." oauth_enabled_warning: "Please note that social logins will be disabled once two factor authentication has been enabled on your account."
@ -1131,9 +1131,8 @@ en:
title: "Log In" title: "Log In"
username: "User" username: "User"
password: "Password" password: "Password"
second_factor_title: "Two Factor Authentication Required" second_factor_title: "Two Factor Authentication"
second_factor_description: "Please enter the authentication code from your app:" second_factor_description: "Please enter the authentication code from your app:"
second_factor_label: "Code"
email_placeholder: "email or username" email_placeholder: "email or username"
caps_lock_warning: "Caps Lock is on" caps_lock_warning: "Caps Lock is on"
error: "Unknown error" error: "Unknown error"