Skip to content

Commit

Permalink
fix(session-mismatch): use same email session token if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLeoB committed Sep 1, 2021
1 parent 2c5f6a2 commit eb20fc0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"components.alerts.currency_update_success": "Currency has been successfully updated",
"components.alerts.deauthorize_browser_error": "Failed to deauthorize this browser.",
"components.alerts.deauthorize_browser_success": "Browser was successfully deauthorized.",
"components.alerts.device_mismatch": "Device mismatch.",
"components.alerts.device_mismatch": "Device mismatch. Please refresh this window or open link in original window.",
"components.alerts.document_upload_error": "Failed to upload document.",
"components.alerts.email_code_sent_success": "Confirmation code has been sent.",
"components.alerts.email_update_error": "Failed to update email address.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ type MessagesType = {
'components.alerts.currency_update_success': 'Currency has been successfully updated'
'components.alerts.deauthorize_browser_error': 'Failed to deauthorize this browser.'
'components.alerts.deauthorize_browser_success': 'Browser was successfully deauthorized.'
'components.alerts.device_mismatch': 'Device mismatch.'
'components.alerts.device_mismatch': 'Device mismatch. Please refresh this window or open link in original window.'
'components.alerts.document_upload_error': 'Failed to upload document.'
'components.alerts.email_code_sent_success': 'Confirmation code has been sent.'
'components.alerts.email_update_error': 'Failed to update email address.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ const getAlertContent = (message, data = undefined) => {
return buildMessageTemplate(
<FormattedMessage
id='components.alerts.device_mismatch'
defaultMessage='Device mismatch.'
defaultMessage='Device mismatch. Please refresh this window or open link in original window.'
/>
)
case C.EMAIL_CODE_SENT_SUCCESS:
Expand Down
13 changes: 8 additions & 5 deletions packages/blockchain-wallet-v4-frontend/src/data/auth/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -707,21 +707,24 @@ export default ({ api, coreSagas, networks }) => {

// triggers verification email for login
const triggerWalletMagicLink = function* (action) {
const { captchaToken, email } = action.payload
const formValues = yield select(selectors.form.getFormValues('login'))
const { step } = formValues
let session = yield select(selectors.session.getSession, null, email)
const legacyMagicEmailLink = (yield select(
selectors.core.walletOptions.getFeatureLegacyMagicEmailLink
)).getOrElse(true)
yield put(startSubmit('login'))
try {
yield put(A.triggerWalletMagicLinkLoading())
const sessionToken = yield call(api.obtainSessionToken)
const { captchaToken, email } = action.payload
yield put(actions.session.saveSession(assoc(email, sessionToken, {})))
if (!session) {
session = yield call(api.obtainSessionToken)
yield put(actions.session.saveSession(assoc(email, session, {})))
}
if (legacyMagicEmailLink) {
yield call(api.triggerWalletMagicLinkLegacy, email, captchaToken, sessionToken)
yield call(api.triggerWalletMagicLinkLegacy, email, captchaToken, session)
} else {
yield call(api.triggerWalletMagicLink, email, captchaToken, sessionToken)
yield call(api.triggerWalletMagicLink, email, captchaToken, session)
}
if (step === LoginSteps.CHECK_EMAIL) {
yield put(actions.alerts.displayInfo(C.VERIFY_EMAIL_SENT))
Expand Down

0 comments on commit eb20fc0

Please sign in to comment.