Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Me: 2fa Reauth Required Improvements #1386

Merged
merged 3 commits into from
Dec 8, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions client/me/reauth-required/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ module.exports = React.createClass( {
} );
},

preValidateAuthCode: function() {
return this.state.code.length && this.state.code.length > 5;
},

renderSendSMSButton: function() {
var button;
if ( this.props.twoStepAuthorization.isTwoStepSMSEnabled() ) {
Expand Down Expand Up @@ -148,14 +152,21 @@ module.exports = React.createClass( {
},

render: function() {
var codePlaceholder = '123456';
var codePlaceholder = this.translate( 'e.g. 123456', {
context: '6 digit two factor code placeholder.',
textOnly: true
} );

if ( this.props.twoStepAuthorization.isTwoStepSMSEnabled() ) {
codePlaceholder = '1234567';
codePlaceholder = this.translate( 'e.g. 1234567', {
context: '7 digit two factor code placeholder.',
textOnly: true
} );
}

return (
<Dialog
autoFocus={ false }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this prop necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my testing it is necessary.

My understanding is the the Dialog component auto focuses on the content by default. So passing in autoFocus={false} short circuits that and allows us to set our own autoFocus.

See this block.

className="reauth-required__dialog"
isFullScreen={ false }
isVisible={ this.props.twoStepAuthorization.isReauthRequired() }
Expand All @@ -177,11 +188,13 @@ module.exports = React.createClass( {
<FormFieldset>
<FormLabel htmlFor="code">{ this.translate( 'Verification Code' ) }</FormLabel>
<FormTelInput
autoFocus={ true }
id="code"
isError={ this.props.twoStepAuthorization.codeValidationFailed() }
name="code"
placeholder={ codePlaceholder }
onFocus={ this.recordFocusEvent( 'Reauth Required Verification Code Field' ) }
ref="code"
valueLink={ this.linkState( 'code' ) } />

{ this.renderFailedValidationMsg() }
Expand All @@ -201,7 +214,10 @@ module.exports = React.createClass( {
{ this.renderSMSResendThrottled() }

<FormButtonsBar>
<FormButton disabled={ this.state.validatingCode } onClick={ this.recordClickEvent( 'Submit Validation Code on Reauth Required' ) } >
<FormButton
disabled={ this.state.validatingCode || ! this.preValidateAuthCode() }
onClick={ this.recordClickEvent( 'Submit Validation Code on Reauth Required' ) }
>
{ this.translate( 'Verify' ) }
</FormButton>

Expand Down