Skip to content

Commit

Permalink
fix(Login): if pw is entered incorrectly, require user to get new 2fa…
Browse files Browse the repository at this point in the history
… code
  • Loading branch information
plondon committed Jun 19, 2018
1 parent fb34d66 commit fd21b7a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
Expand Up @@ -273,7 +273,7 @@ export default ({ api, coreSagas }) => {
const { guid } = action.payload
const sessionToken = yield select(selectors.session.getSession, guid)
const response = yield call(coreSagas.wallet.resendSmsLoginCode, { guid, sessionToken })
if (response.initial_error) {
if (response.initial_error && !response.initial_error.includes('login attempts left')) {
throw new Error(response)
} else {
yield put(actions.alerts.displaySuccess(C.SMS_RESEND_SUCCESS))
Expand Down
Expand Up @@ -11,19 +11,13 @@ class LoginContainer extends React.PureComponent {
super(props)
this.state = { useCode: true }
this.onSubmit = this.onSubmit.bind(this)
this.handleCode = this.handleCode.bind(this)
this.handleMobile = this.handleMobile.bind(this)
this.handleSmsResend = this.handleSmsResend.bind(this)
}

handleCode (val) {
this.setState({ useCode: val })
}

onSubmit () {
const { useCode } = this.state
const { guid, password, code } = this.props
let auth = useCode ? code : undefined
let auth = code
// only uppercase if authType is not Yubikey
if (auth && this.props.authType !== 1) {
auth = auth.toUpperCase()
Expand Down Expand Up @@ -54,7 +48,6 @@ class LoginContainer extends React.PureComponent {
authType,
loginError: error,
onSubmit: this.onSubmit,
handleCode: this.handleCode,
handleMobile: this.handleMobile,
handleSmsResend: this.handleSmsResend
}
Expand Down
Expand Up @@ -70,8 +70,6 @@ const Login = (props) => {
const twoFactorError = loginError && loginError.toLowerCase().includes('authentication code')
const accountLocked = loginError && (loginError.toLowerCase().includes('this account has been locked') || loginError.toLowerCase().includes('account is locked'))

const handlePasswordChange = () => { passwordError && props.handleCode(false) }

return (
<Wrapper>
<Modals>
Expand Down Expand Up @@ -143,7 +141,7 @@ const Login = (props) => {
<FormLabel for='password'>
<FormattedMessage id='scenes.login.password' defaultMessage='Password' />
</FormLabel>
<Field name='password' validate={[required]} component={PasswordBox} onChange={handlePasswordChange} borderColor={passwordError ? 'invalid' : undefined} disabled={!isSupportedBrowser} />
<Field name='password' validate={[required]} component={PasswordBox} borderColor={passwordError ? 'invalid' : undefined} disabled={!isSupportedBrowser} />
{ passwordError && <FormError position={authType > 0 ? 'relative' : 'absolute'}><FormattedMessage id='scenes.login.wrong_password' defaultMessage='Error decrypting wallet. Wrong password' /></FormError> }
{ accountLocked && <FormError position={authType > 0 || passwordError ? 'relative' : 'absolute'}>{loginError}</FormError> }
</FormItem>
Expand Down

0 comments on commit fd21b7a

Please sign in to comment.