Skip to content

Commit

Permalink
fix(ip-restriction-alert): added alert for accounts that restricts ip
Browse files Browse the repository at this point in the history
  • Loading branch information
jjBlockchain committed Sep 9, 2019
1 parent 192a05d commit 8a5c653
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { FormattedMessage } from 'react-intl'
import { FormattedMessage, FormattedHTMLMessage } from 'react-intl'
import styled from 'styled-components'

import { Icon, Link, Text, TextGroup } from 'blockchain-info-components'
Expand Down Expand Up @@ -378,6 +378,13 @@ export const getAlertContent = (message, data = undefined, handleClose, id) => {
defaultMessage='Incorrect BIP38 password.'
/>
)
case C.IPRESTRICTION_LOGIN_ERROR:
return buildMessageTemplate(
<FormattedHTMLMessage
id='components.alerts.iprestriction_login_error'
defaultMessage='This wallet is restricted to another IP address. To remove this restriction, submit a 2FA reset request under <a href="/help">Need Some Help?</a>.'
/>
)
case C.IPRESTRICTION_NO_WHITELIST_ERROR:
return buildMessageTemplate(
<FormattedMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const Alerts = props => {
<Wrapper>
{alerts.map(alert => {
const { id, nature, message, data, coin, persist, timeout } = alert
const dismissTimer = timeout || 7000
let dismissTimer = timeout || 7000
return (
<Toast
key={id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ export const displayInfo = (message, data, persist, timeout) =>
export const displaySuccess = (message, data, persist, timeout) =>
display('success', message, data, persist, timeout)

export const displayError = (message, data, persist, timeout) =>
display('error', message, data, persist, timeout)
export const displayError = (message, data, persist, coin, timeout) => {
let dismissTimer = timeout
if (message === 'iprestriction_login_error') dismissTimer = 9500
return display('error', message, data, persist, coin, dismissTimer)
}

export const displayCoin = (message, coin, persist, timeout) =>
display(null, message, null, persist, timeout, coin)
Expand Down
4 changes: 4 additions & 0 deletions packages/blockchain-wallet-v4-frontend/src/data/auth/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,11 @@ export default ({ api, coreSagas }) => {
yield put(actions.form.focus('login', 'password'))
yield put(actions.auth.loginFailure(error))
} else if (initialError) {
const ipRestriction =
'This wallet is restricted to another IP address. To remove this restriction, submit a 2FA reset request under Login Help.'
// general error
if (initialError === ipRestriction)
yield put(actions.alerts.displayError(C.IPRESTRICTION_LOGIN_ERROR))
yield put(actions.auth.loginFailure(initialError))
} else if (
// Wrong 2fa code error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const HINT_UPDATE_ERROR = 'hint_update_error'
export const HINT_UPDATE_SUCCESS = 'hint_update_success'
export const IMPORT_LEGACY_SUCCESS = 'import_legacy_success'
export const INCORRECT_BIP38_PASSWORD_ERROR = 'incorrect_bip38_password_error'
export const IPRESTRICTION_LOGIN_ERROR = 'iprestriction_login_error'
export const IPRESTRICTION_NO_WHITELIST_ERROR =
'iprestriction_no_whitelist_error'
export const IPRESTRICTION_UPDATE_ERROR = 'iprestriction_update_error'
Expand Down

0 comments on commit 8a5c653

Please sign in to comment.