aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.43k stars 2.13k forks source link

Auth.signin() throw error: "Device does not exist." when migrate user #10083

Closed longnt-dev closed 2 years ago

longnt-dev commented 2 years ago

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Authentication

Amplify Categories

auth

Environment information

``` # Put output below this line System: OS: macOS 12.4 CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz Memory: 10.58 GB / 64.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.2.0 - /usr/local/bin/node Yarn: 1.22.11 - /usr/local/bin/yarn npm: 8.1.3 - ~/Source/Mango/mango-react-native/node_modules/.bin/npm Browsers: Chrome: 103.0.5060.114 Safari: 15.5 npmPackages: @apollo/client: ^3.5.9 => 3.5.9 (3.6.9) @apollo/client/cache: undefined () @apollo/client/core: undefined () @apollo/client/errors: undefined () @apollo/client/link/batch: undefined () @apollo/client/link/batch-http: undefined () @apollo/client/link/context: undefined () @apollo/client/link/core: undefined () @apollo/client/link/error: undefined () @apollo/client/link/http: undefined () @apollo/client/link/persisted-queries: undefined () @apollo/client/link/retry: undefined () @apollo/client/link/schema: undefined () @apollo/client/link/subscriptions: undefined () @apollo/client/link/utils: undefined () @apollo/client/link/ws: undefined () @apollo/client/react: undefined () @apollo/client/react/components: undefined () @apollo/client/react/context: undefined () @apollo/client/react/hoc: undefined () @apollo/client/react/hooks: undefined () @apollo/client/react/parser: undefined () @apollo/client/react/ssr: undefined () @apollo/client/testing: undefined () @apollo/client/testing/core: undefined () @apollo/client/utilities: undefined () @apollo/client/utilities/globals: undefined () @babel/core: ^7.12.9 => 7.16.0 (7.17.9) @babel/plugin-syntax-flow: ^7.16.7 => 7.16.7 (7.16.0) @babel/plugin-transform-react-jsx: ^7.17.3 => 7.17.3 (7.16.0) @babel/preset-env: ^7.16.11 => 7.16.11 @babel/runtime: ^7.12.5 => 7.16.3 (7.17.9) @codler/react-native-keyboard-aware-scroll-view: ^2.0.0 => 2.0.0 @commitlint/cli: ^12.1.1 => 12.1.4 @commitlint/config-conventional: ^12.1.1 => 12.1.4 @mango-engineering/maknet-client-sdk: ^1.30.0 => 1.30.0 @react-native-async-storage/async-storage: ^1.16.1 => 1.16.1 (1.17.3) @react-native-community/clipboard: ^1.5.1 => 1.5.1 @react-native-community/datetimepicker: ^3.5.2 => 3.5.2 @react-native-community/eslint-config: ^3.0.1 => 3.0.1 @react-native-community/masked-view: ^0.1.10 => 0.1.11 @react-native-community/netinfo: ^6.0.0 => 6.1.0 @react-native-community/push-notification-ios: ^1.8.0 => 1.10.1 @react-native-firebase/analytics: ^11.0.0 => 11.5.0 (12.9.3) @react-native-firebase/app: ^11.0.0 => 11.5.0 (12.9.3) @react-native-firebase/auth: ^11.0.0 => 11.5.0 @react-native-firebase/crashlytics: ^11.0.0 => 11.5.0 @react-native-firebase/dynamic-links: ^11.0.0 => 11.5.0 @react-native-firebase/messaging: ^11.0.0 => 11.5.0 @react-native-firebase/perf: ^11.0.0 => 11.5.0 @react-native-firebase/remote-config: ^11.0.0 => 11.5.0 @react-native-picker/picker: ^2.4.0 => 2.4.0 (1.16.8) @react-navigation/bottom-tabs: ^5.11.10 => 5.11.15 @react-navigation/material-top-tabs: ^5.x => 5.3.19 @react-navigation/native: ^5.9.4 => 5.9.8 @react-navigation/stack: 5.14.4 => 5.14.4 @reduxjs/toolkit: ^1.6.2 => 1.6.2 @reduxjs/toolkit-query: 1.0.0 @reduxjs/toolkit-query-react: 1.0.0 @segment/analytics-react-native: ^2.1.11 => 2.1.11 @segment/analytics-react-native-plugin-amplitude-session: ^0.2.1 => 0.2.1 @segment/analytics-react-native-plugin-firebase: ^0.2.1 => 0.2.1 @segment/sovran-react-native: ^0.2.6 => 0.2.6 @sideway/address: ^4.1.2 => 4.1.2 @storybook/react-native: ^6.0.1-beta.6 => 6.0.1-beta.6 @testing-library/react-native: ^9.0.0 => 9.0.0 @twotalltotems/react-native-otp-input: ^1.3.11 => 1.3.11 @types/algoliasearch: ^4.0.0 => 4.0.0 @types/jest: ^26.0.20 => 26.0.24 @types/react: ^17.0.5 => 17.0.5 (17.0.4) @types/react-instantsearch-native: ^6.3.2 => 6.3.2 @types/react-native: ^0.65.1 => 0.65.22 (0.67.4) @types/react-native-snap-carousel: ^3.8.3 => 3.8.5 @types/react-test-renderer: ^17.0.1 => 17.0.1 @types/uuid: ^8.3.4 => 8.3.4 @typescript-eslint/eslint-plugin: ^5.14.0 => 5.14.0 (4.33.0) @typescript-eslint/parser: ^5.14.0 => 5.14.0 (4.33.0) HelloWorld: 0.0.1 algoliasearch: ^4.12.0 => 4.12.0 (4.11.0) amazon-cognito-identity-js: ^5.2.9 => 5.2.9 apollo-link-timeout: ^4.0.0 => 4.0.0 apollo3-cache-persist: ^0.14.0 => 0.14.0 aws-amplify: ^4.3.24 => 4.3.24 aws-amplify-react-native: ^6.0.4 => 6.0.4 axios: ^0.21.1 => 0.21.4 babel-jest: ^27.5.0 => 27.5.0 (27.3.1) babel-plugin-root-import: ^6.6.0 => 6.6.0 buffer: ^6.0.3 => 6.0.3 (4.9.2, 5.7.1) currency-symbol-map: ^5.0.1 => 5.0.1 dayjs: ^1.10.7 => 1.10.7 eslint: 7.32.0 => 7.32.0 eslint-import-resolver-typescript: ^2.5.0 => 2.5.0 fast-text-encoding: ^1.0.3 => 1.0.3 flag: ^4.4.0 => 4.4.0 formik: ^2.2.9 => 2.2.9 graphql: ^15.5.0 => 15.7.2 (15.8.0, 16.5.0) hermes-inspector-msggen: 1.0.0 husky: ^7.0.0 => 7.0.4 i18next: ^20.3.1 => 20.6.1 jail-monkey: ^2.6.0 => 2.6.0 jest: ^27.2.1 => 27.3.1 jest-fetch-mock: ^3.0.3 => 3.0.3 jest-sonar-reporter: ^2.0.0 => 2.0.0 joi: ^17.4.2 => 17.4.2 (17.4.0) lint-staged: ^10.5.4 => 10.5.4 lottie-ios: ^3.2.3 => 3.2.3 lottie-react-native: ^5.0.1 => 5.0.1 metro-config: ^0.66.2 => 0.66.2 (0.67.0) metro-react-native-babel-preset: ^0.66.2 => 0.66.2 (0.67.0) prettier: ^2.5.1 => 2.5.1 (2.6.2) prop-types: ^15.8.1 => 15.8.1 (15.7.2) react: 17.0.2 => 17.0.2 react-content-loader: ^6.0.3 => 6.0.3 react-content-loader/native: undefined () react-dom: 17.0.2 => 17.0.2 react-i18next: ^11.10.0 => 11.14.2 react-instantsearch: ^6.15.0 => 6.15.0 react-instantsearch-native: ^6.15.0 => 6.15.0 react-native: 0.68.1 => 0.68.1 react-native-background-timer: ^2.4.1 => 2.4.1 react-native-codegen: ^0.0.7 => 0.0.7 (0.0.13) react-native-component-inview: ^1.0.2 => 1.0.2 react-native-config: ^1.4.4 => 1.4.5 react-native-confirmation-code-field: ^7.3.0 => 7.3.0 react-native-device-info: ^8.1.3 => 8.4.6 react-native-elements: ^3.4.2 => 3.4.2 react-native-exit-app: ^1.1.0 => 1.1.0 react-native-fast-image: ^8.5.11 => 8.5.11 react-native-flash-message: ^0.2.0 => 0.2.0 react-native-flipper: ^0.146.1 => 0.146.1 react-native-geolocation-service: ^5.3.0-beta.4 => 5.3.0-beta.4 react-native-gesture-handler: ^1.10.3 => 1.10.3 react-native-get-random-values: ^1.7.2 => 1.7.2 (1.8.0) react-native-in-app-review: ^3.3.2 => 3.3.2 react-native-keychain: ^7.0.0 => 7.0.0 react-native-linear-gradient: ^2.5.6 => 2.5.6 react-native-localize: ^2.1.0 => 2.1.5 react-native-lottie-splash-screen: ^0.1.14 => 0.1.14 react-native-mask-input: ^1.0.3 => 1.0.4 react-native-offline: ^6.0.0 => 6.0.0 react-native-onetrust-cmp-upd: ^6.35.0 => 6.35.0 react-native-otp-autocomplete: ^1.0.7 => 1.0.7 react-native-permissions: ^3.3.1 => 3.3.1 react-native-picker-select: ^8.0.4 => 8.0.4 react-native-push-notification: ^7.4.0 => 7.4.0 react-native-raw-bottom-sheet: ^2.2.0 => 2.2.0 react-native-reanimated: 2.4.1 => 2.4.1 react-native-reanimated-carousel: 2.3.2 => 2.3.2 react-native-render-html: ^6.3.0 => 6.3.0 react-native-safe-area-context: ^3.2.0 => 3.3.2 react-native-screens: ^3.0.0 => 3.9.0 (3.13.1) react-native-skeleton-content-nonexpo: ^1.0.13 => 1.0.13 react-native-snap-carousel: ^3.9.1 => 3.9.1 react-native-status-bar-height: ^2.6.0 => 2.6.0 react-native-svg: ^12.1.1 => 12.1.1 react-native-swiper: ^1.6.0 => 1.6.0 react-native-tab-view: ^2.x => 2.16.0 react-native-tracking-transparency: ^0.1.1 => 0.1.1 react-native-url-polyfill: ^1.3.0 => 1.3.0 react-native-vector-icons: ^8.1.0 => 8.1.0 react-native-webview: ^11.14.0 => 11.14.2 react-redux: ^7.2.3 => 7.2.6 react-test-renderer: ^17.0.2 => 17.0.2 redux: ^4.0.5 => 4.1.2 redux-flipper: ^2.0.1 => 2.0.1 redux-persist: ^6.0.0 => 6.0.0 redux-persist/integration/react: undefined () redux-saga: ^1.1.3 => 1.1.3 redux-saga/effects: undefined () shopify-storefront-api-typings: ^1.2.1 => 1.2.1 source-map: ^0.7.3 => 0.7.3 (0.5.7, 0.6.1, 0.5.6) toggle-switch-react-native: ^3.3.0 => 3.3.0 ts-jest: ^27.1.3 => 27.1.3 typed-redux-saga: ^1.3.1 => 1.3.1 () typescript: ^4.2.4 => 4.4.4 uuid: ^8.3.2 => 8.3.2 (3.4.0, 3.3.2, 7.0.3) yarn-audit-fix: ^7.0.8 => 7.2.0 yup: ^0.32.9 => 0.32.11 npmGlobalPackages: @nestjs/cli: 8.1.1 expo-cli: 4.10.0 jest: 27.1.1 node-gyp: 8.2.0 npm: 7.13.0 react-devtools: 4.11.0 rimraf: 3.0.2 tsc: 2.0.3 yarn: 1.22.11 ```

Describe the bug

CONTEXT: we are trying to migrate user account from old user pool to Cognito User Pool, we use User Migration lambda function for the job. ISSUE: When we try to login ( using Auth.signin() ) using email/password of user from old user pool, most of the time it migrates user successfully. However, sometimes we receive that issue: "Device does not exist." NOTICE: We recognize that this issue happen for account which is recently migrated successfully and then deleted from user pool.

Expected behavior

User should be migrated successfully without any issue

Reproduction steps

  1. Setup User Migration Lambda code to migrate user
  2. Trigger Auth.signin() from the React Native App
  3. App throw error: "Device does not exist."

Code Snippet

// Put your code below this line.
function* loginWithEmailSaga(
  action: PayloadAction<LoginWithEmailActionPayload>,
): Generator {
  try {
    yield* put(setLoadingAction(true))

    const { email, password } = action.payload
    if (email && password) {
      const data = yield* call(() => {
        return Auth.signIn(email.split('@')[0], password, { email: email })
      })
      if (data) {
        yield* put(getUserSessionAction())
      }
    }
  } catch (e) {
    console.error(e?.message)
    yield* put(setLoadingAction(false))
    yield* call(showFlashMessage, {
      type: 'danger',
      icon: 'danger',
      message: i18n.t('login.message.loginFailed'),
    })
  } finally {
    yield* put(authorizeAction())
    yield* put(setLoadingAction(false))
  }
}

Log output

``` // Put your logs below this line ```

aws-exports.js

No response

Manual configuration

Amplify.configure({ Auth: { userPoolId: currentEnvConfig[COGNITO_USER_POOL_ID], userPoolWebClientId: currentEnvConfig[COGNITO_USER_POOL_WEB_CLIENT_ID], authenticationFlowType: AuthenticationFlowType.USER_PASSWORD_AUTH, }, })

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

tannerabread commented 2 years ago

@longnt-dev did you have device remembering enabled on your initial cognito user pool?

tannerabread commented 2 years ago

Hi 👋 Closing this as we have not heard back from you. If you are still experiencing this issue and in need of assistance, please feel free to comment and provide us with any information previously requested by our team members so we can re-open this issue and be better able to assist you.

Thank you!