Skip to content

Commit

Permalink
feat(sso): separate wallet and exchange 2fa steps
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLeoB committed Dec 1, 2021
1 parent f0df8db commit 946b3cb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 25 deletions.
9 changes: 5 additions & 4 deletions packages/blockchain-wallet-v4-frontend/src/data/auth/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default ({ api, coreSagas, networks }) => {
} catch (e) {
yield put(actions.auth.exchangeLoginFailure(e.code))
if (e.code && e.code === 11) {
yield put(actions.form.change(LOGIN_FORM, 'step', LoginSteps.TWO_FA))
yield put(actions.form.change(LOGIN_FORM, 'step', LoginSteps.TWO_FA_EXCHANGE))
}
yield put(stopSubmit(LOGIN_FORM))
}
Expand Down Expand Up @@ -317,7 +317,7 @@ export default ({ api, coreSagas, networks }) => {
if (typeof error !== 'string' && error?.auth_type > 0) {
yield put(actions.auth.setAuthType(error.auth_type))
yield put(actions.alerts.displayInfo(C.TWOFA_REQUIRED_INFO))
yield put(actions.form.change(LOGIN_FORM, 'step', LoginSteps.TWO_FA))
yield put(actions.form.change(LOGIN_FORM, 'step', LoginSteps.TWO_FA_WALLET))
yield put(actions.auth.loginFailure(undefined))
// otherwise only other error could be wrong wallet password
} else {
Expand All @@ -333,7 +333,7 @@ export default ({ api, coreSagas, networks }) => {
case typeof error !== 'string' && error.auth_type > 0:
yield put(actions.auth.loginFailure(undefined))
yield put(actions.auth.setAuthType(typeof error !== 'string' && error.auth_type))
yield put(actions.form.change(LOGIN_FORM, 'step', LoginSteps.TWO_FA))
yield put(actions.form.change(LOGIN_FORM, 'step', LoginSteps.TWO_FA_WALLET))
yield put(actions.alerts.displayInfo(C.TWOFA_REQUIRED_INFO))
break
// Wrong wallet password error is just returned as a string
Expand Down Expand Up @@ -617,6 +617,7 @@ export default ({ api, coreSagas, networks }) => {
} = yield select(selectors.form.getFormValues(LOGIN_FORM))
const authType = yield select(selectors.auth.getAuthType)
const language = yield select(selectors.preferences.getLanguage)
const product = yield select(S.getProduct)
try {
// set code to uppercase if type is not yubikey
let auth = code
Expand All @@ -643,7 +644,7 @@ export default ({ api, coreSagas, networks }) => {
// Passing ID type used to analytics
const idType = isGuid(guidOrEmail) ? 'WALLET_ID' : 'EMAIL'
yield put(actions.auth.analyticsLoginIdEntered(idType))
} else if (step === LoginSteps.ENTER_PASSWORD_WALLET) {
} else if (step === LoginSteps.ENTER_PASSWORD_WALLET || step === LoginSteps.TWO_FA_WALLET) {
yield put(
actions.auth.login({ code: auth, guid, mobileLogin: null, password, sharedKey: null })
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export enum LoginSteps {
LOADING = 'LOADING',
PRODUCT_PICKER_AFTER_AUTHENTICATION = 'PRODUCT_PICKER_AFTER_AUTHENTICATION',
PRODUCT_PICKER_BEFORE_AUTHENTICATION = 'PRODUCT_PICKER_BEFORE_AUTHENTICATION',
TWO_FA = 'TWO_FA',
TWO_FA_EXCHANGE = 'TWO_FA_EXCHANGE',
TWO_FA_WALLET = 'TWO_FA_WALLET',
UPGRADE_CONFIRM = 'UPGRADE_CONFIRM',
UPGRADE_PASSWORD = 'UPGRADE_PASSWORD',
UPGRADE_SUCCESS = 'UPGRADE_SUCCESS',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,10 @@ class Login extends PureComponent<InjectedFormProps<{}, Props> & Props, StatePro
return <EnterPasswordExchange {...loginProps} />
case LoginSteps.ENTER_PASSWORD_WALLET:
return <EnterPasswordWallet {...loginProps} />
case LoginSteps.TWO_FA:
return product === ProductAuthOptions.EXCHANGE ? (
<TwoFAExchange {...loginProps} />
) : (
<TwoFAWallet {...loginProps} />
)
case LoginSteps.TWO_FA_EXCHANGE:
return <TwoFAExchange {...loginProps} />
case LoginSteps.TWO_FA_WALLET:
return <TwoFAWallet {...loginProps} />
case LoginSteps.CHECK_EMAIL:
return <CheckEmail {...loginProps} />
case LoginSteps.VERIFY_MAGIC_LINK:
Expand Down
26 changes: 12 additions & 14 deletions packages/blockchain-wallet-v4-frontend/src/scenes/Login/model.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,20 +242,18 @@ margin-top: 0;
`
export const SignUpLink = () => (
<LinkContainer data-e2e='signupLink' to='/signup'>
<Link>
<SubCard>
<Text size='16px' color='grey600' weight={500} style={{ marginTop: '16px' }}>
<FormattedMessage
id='scenes.login.account_signup'
defaultMessage="Don't have a Blockchain Account?"
/>
</Text>
&nbsp;
<SignUpText size='16px' color='blue600' weight={600}>
<FormattedMessage id='buttons.signup_now' defaultMessage='Sign up Now ->' />
</SignUpText>
</SubCard>
</Link>
<SubCard>
<Text size='16px' color='grey600' weight={500} style={{ marginTop: '16px' }}>
<FormattedMessage
id='scenes.login.account_signup'
defaultMessage="Don't have a Blockchain Account?"
/>
</Text>
&nbsp;
<SignUpText size='16px' color='blue600' weight={600}>
<FormattedMessage id='buttons.signup_now' defaultMessage='Sign up Now ->' />
</SignUpText>
</SubCard>
</LinkContainer>
)
export const UnsupportedBrowserWarning = () => (
Expand Down

0 comments on commit 946b3cb

Please sign in to comment.