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.verifiedContact returning email as unverified if email_verified="True" (uppercase) #8205

Closed ybonjour closed 3 years ago

ybonjour commented 3 years ago

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

Authentication

Amplify Categories

auth

Environment information

``` npx: installed 1 in 1.594s System: OS: macOS 10.15.7 CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz Memory: 929.91 MB / 16.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.18.3 - ~/.nvm/versions/node/v12.18.3/bin/node Yarn: 1.22.4 - ~/dev/tooltime/web/node_modules/.bin/yarn npm: 6.14.6 - ~/.nvm/versions/node/v12.18.3/bin/npm Browsers: Chrome: 90.0.4430.93 Safari: 13.1.3 npmPackages: @apollo/react-testing: 3.1.0 => 3.1.0 @babel/core: 7.7.4 => 7.7.4 (7.13.15, 7.6.3, 7.12.9, 7.8.7) @babel/runtime: 7.6.2 => 7.6.2 (7.6.3, 7.10.2, 7.7.2, 7.7.6, 7.13.10, 7.11.2, 7.7.4, 7.13.9, 7.9.2) @date-io/moment: 1.3.5 => 1.3.5 @material-ui/core: 4.5.1 => 4.5.1 @material-ui/icons: 3.0.2 => 3.0.2 @material-ui/pickers: 3.2.10 => 3.2.10 @my-scope/package-a: 0.0.0 @my-scope/package-b: 0.0.0 @sentry/browser: 5.26.0 => 5.26.0 @sentry/cli: 1.52.4 => 1.52.4 @storybook/addon-actions: 6.2.8 => 6.2.8 @storybook/addon-essentials: 6.2.8 => 6.2.8 @storybook/addon-links: 6.2.8 => 6.2.8 @storybook/react: 6.2.8 => 6.2.8 @testing-library/jest-dom: 5.1.1 => 5.1.1 @testing-library/react: 10.3.0 => 10.3.0 @testing-library/react-hooks: 3.4.1 => 3.4.1 @tooltime2019/eslint-config-tooltime: 2.2.0 => 2.2.0 @types/autosuggest-highlight: 3.1.0 => 3.1.0 @types/enzyme: 3.1.16 => 3.1.16 @types/googlemaps: 3.37.6 => 3.37.6 @types/history: 4.7.3 => 4.7.3 @types/i18next: 12.1.0 => 12.1.0 @types/jest: 23.3.12 => 23.3.12 (25.1.4) @types/lodash: ^4.14.168 => 4.14.168 @types/mixpanel-browser: 2.23.0 => 2.23.0 @types/ms: 0.7.31 => 0.7.31 @types/node: 10.12.18 => 10.12.18 (12.7.12, 14.14.41, 12.12.50, 14.11.2, 13.13.15) @types/numeral: 0.0.25 => 0.0.25 @types/react: 16.9.5 => 16.9.5 @types/react-beautiful-dnd: 13.0.0 => 13.0.0 @types/react-dom: 16.9.4 => 16.9.4 (16.9.1) @types/react-paginate: 6.2.1 => 6.2.1 @types/react-redux: 7.1.5 => 7.1.5 @types/react-router-dom: ^5.1.6 => 5.1.6 @types/react-select: 3.0.4 => 3.0.4 @types/react-test-renderer: 16.9.1 => 16.9.1 (16.9.3) @types/redux-mock-store: 1.0.1 => 1.0.1 @types/uuid: 3.4.5 => 3.4.5 @types/yup: 0.26.37 => 0.26.37 apollo: 2.31.0 => 2.31.0 apollo-cache: 1.3.2 => 1.3.2 apollo-cache-inmemory: 1.6.3 => 1.6.3 apollo-client: 2.6.4 => 2.6.4 apollo-link: 1.2.12 => 1.2.12 (1.2.13, 1.2.14) apollo-link-error: 1.1.12 => 1.1.12 apollo-link-http: 1.5.16 => 1.5.16 apollo-link-sentry: 1.3.1 => 1.3.1 apollo-link-timeout: 1.4.0 => 1.4.0 apollo-utilities: 1.3.2 => 1.3.2 autosuggest-highlight: 3.1.1 => 3.1.1 aws-amplify: 3.3.27 => 3.3.27 aws-amplify-react: 4.2.31 => 4.2.31 babel-jest: 24.9.0 => 24.9.0 (25.5.1) babel-loader: 8.0.6 => 8.0.6 (8.2.2) babel-plugin-named-asset-import: 0.3.5 => 0.3.5 (0.3.7) babel-preset-react-app: 9.1.0 => 9.1.0 baz: undefined () browser_field: undefined () camelcase: 5.3.1 => 5.3.1 (5.0.0) case-sensitive-paths-webpack-plugin: 2.2.0 => 2.2.0 (2.4.0) chalk: 4.1.0 => 4.1.0 (2.4.2, 1.1.3, 3.0.0) clsx: 1.0.4 => 1.0.4 (1.1.1) core-js: 3.0.0 => 3.0.0 (3.6.4, 3.2.1, 3.6.5, 3.10.1, 2.6.9, 1.2.7) css-loader: 3.2.0 => 3.2.0 (3.6.0) cypress: 6.5.0 => 6.5.0 depcheck: 0.9.2 => 0.9.2 depcheck-test-e2e: 0.0.1 dependency-cruiser: 9.15.0 => 9.15.0 dotenv: 8.2.0 => 8.2.0 (8.1.0, 6.2.0) dotenv-expand: 5.1.0 => 5.1.0 emotion: 10.0.23 => 10.0.23 enzyme: 3.8.0 => 3.8.0 enzyme-adapter-react-16: 1.14.0 => 1.14.0 eslint: 7.9.0 => 7.9.0 eslint-config-airbnb-typescript: 10.0.0 => 10.0.0 eslint-config-prettier: ^8.1.0 => 8.1.0 (6.11.0) eslint-loader: 3.0.2 => 3.0.2 eslint-plugin-import: 2.22.0 => 2.22.0 eslint-plugin-intercom-attribute: file:./eslint-rules/intercom-attribute => 1.0.0 eslint-plugin-jsx-a11y: 6.3.1 => 6.3.1 eslint-plugin-prettier: ^3.3.1 => 3.3.1 (3.1.2) eslint-plugin-react: 7.20.3 => 7.20.3 eslint-plugin-react-hooks: 4.0.8 => 4.0.8 file-loader: 4.3.0 => 4.3.0 (6.2.0) firebase: 7.17.1 => 7.17.1 firebase/analytics: undefined () firebase/app: undefined () firebase/auth: undefined () firebase/database: undefined () firebase/firestore: undefined () firebase/firestore/memory: undefined () firebase/functions: undefined () firebase/installations: undefined () firebase/messaging: undefined () firebase/performance: undefined () firebase/remote-config: undefined () firebase/storage: undefined () fs-extra: 8.1.0 => 8.1.0 (9.0.1, 7.0.1, 9.1.0, 0.30.0, 4.0.3) graphql: 14.5.8 => 14.5.8 graphql-tag: 2.10.1 => 2.10.1 (2.11.0) history: 4.10.1 => 4.10.1 html-webpack-plugin: 4.0.0-beta.5 => 4.0.0-beta.5 (4.5.2) husky: 1.3.1 => 1.3.1 hygen: 6.0.4 => 6.0.4 i18next: 17.0.15 => 17.0.15 immer: 8.0.1 => 8.0.1 (1.10.0) invalid main: undefined () jest: 25.1.0 => 25.1.0 jest-canvas-mock: 2.1.2 => 2.1.2 jest-environment-jsdom-fourteen: 1.0.1 => 1.0.1 jest-sonar-reporter: 2.0.0 => 2.0.0 jest-watch-typeahead: 0.4.2 => 0.4.2 js-sha256: 0.9.0 => 0.9.0 lint-staged: 10.0.0 => 10.0.0 lodash: 4.17.21 => 4.17.21 (4.17.19, 4.17.20) memo-parser: 0.2.1 mini-css-extract-plugin: 0.8.0 => 0.8.0 mixpanel-browser: 2.27.1 => 2.27.1 moment: 2.24.0 => 2.24.0 (2.29.1, 2.28.0) monorepo-symlink-test: 0.0.0 ms: 2.1.2 => 2.1.2 (2.1.1, 2.0.0) mylib: 0.0.0 node-fetch: 2.6.1 => 2.6.1 (1.7.3) normalizr: 3.6.1 => 3.6.1 numeral: 2.0.6 => 2.0.6 optimize-css-assets-webpack-plugin: 5.0.3 => 5.0.3 pnp-webpack-plugin: 1.5.0 => 1.5.0 (1.6.4) postcss-flexbugs-fixes: 4.1.0 => 4.1.0 (4.2.1) postcss-loader: 3.0.0 => 3.0.0 (4.2.0) postcss-normalize: 8.0.1 => 8.0.1 postcss-preset-env: 6.7.0 => 6.7.0 postcss-safe-parser: 4.0.1 => 4.0.1 prettier: ^2.2.1 => 2.2.1 (1.19.1) print-js: 1.0.61 => 1.0.61 query-string: 6.8.3 => 6.8.3 (4.3.4) react: 16.12.0 => 16.12.0 react-apollo: 3.1.0 => 3.1.0 react-app-polyfill: 1.0.6 => 1.0.6 react-beautiful-dnd: 13.0.0 => 13.0.0 react-dev-utils: 10.0.0 => 10.0.0 (11.0.4) react-dom: 16.12.0 => 16.12.0 react-dropzone: 10.1.10 => 10.1.10 react-hook-form: 5.5.3 => 5.5.3 react-i18next: 10.13.1 => 10.13.1 react-number-format: 4.2.0 => 4.2.0 react-paginate: 6.3.0 => 6.3.0 react-redux: 7.1.3 => 7.1.3 (7.2.2) react-router-dom: 5.1.2 => 5.1.2 react-select: 3.0.8 => 3.0.8 react-test-renderer: 16.12.0 => 16.12.0 (16.10.2) redux: 4.0.4 => 4.0.4 redux-dynamic-modules: 5.2.3 => 5.2.3 redux-dynamic-modules-saga: 5.2.3 => 5.2.3 redux-mock-store: 1.5.3 => 1.5.3 redux-saga: 1.1.3 => 1.1.3 redux-saga-testing: 2.0.1 => 2.0.1 redux-saga/effects: undefined () resolve: 1.12.2 => 1.12.2 (1.12.0, 1.20.0, 1.1.7, 1.15.1, 1.17.0, 1.7.1) resolve-url-loader: 3.1.1 => 3.1.1 source-map-explorer: 2.2.0 => 2.2.0 start-server-and-test: 1.10.5 => 1.10.5 style-loader: 1.0.0 => 1.0.0 (1.3.0) terser-webpack-plugin: 2.2.1 => 2.2.1 (3.1.0, 1.4.3) ts-pnp: 1.1.5 => 1.1.5 (1.2.0, 1.1.4) ts-unused-exports: 6.2.4 => 6.2.4 typesafe-actions: 5.1.0 => 5.1.0 typescript: 4.1.2 => 4.1.2 (3.9.5) url-loader: 2.3.0 => 2.3.0 (4.1.1) utility-types: 3.10.0 => 3.10.0 uuid: 3.3.2 => 3.3.2 (3.3.3, 3.4.0) webpack: 4.42.0 => 4.42.0 (4.46.0) webpack-bundle-analyzer: ^4.4.0 => 4.4.0 webpack-dev-server: 3.9.0 => 3.9.0 webpack-manifest-plugin: 2.2.0 => 2.2.0 workbox-webpack-plugin: 4.3.1 => 4.3.1 yargs: 15.4.1 => 15.4.1 (15.1.0, 12.0.5) yup: 0.28.4 => 0.28.4 npmGlobalPackages: @vue/cli: 4.5.12 npm: 6.14.6 ```

Describe the bug

In the Cognito User Pool we have users with verified email adresses. But the email verified Attribute was set to "True" through the AWS SDK.

When we now call Auth.verifiedContact(user) with one of these users it returns the email address as an unverified item.

The problem is that

Expected behavior

In this case I would expect Auth.verfiedContact to return the email address as verified. This also used to be the case for older aws-amplify versions.

Reproduction steps

  1. Create a user through Amazon SDK with CognitoIdentityProviderClient.adminCreateUser and add an attribute with key "email_verfied" and value "True" (uppercase)
  2. Call Auth.verifiedContact with that user.
  3. It declares the email address as unverified. I would expect it to be verified.

More concrete I would expect Auth.attributesToObject to treat attribute values that represent booleans as not case sensitive. So instead of

attribute.Value === 'true' || attribute.Value === true;

I would expect something like

attribute.Value.toLowerCase() === 'true' || attribute.Value === true;

Code Snippet

// Put your code below this line.

Log output

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

aws-exports.js

No response

Manual configuration

No response

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

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

chrisbonifacio commented 3 years ago

Hey @ybonjour ! Closing this issue since we got that PR merged. If you happen to run into this issue again, please re-open this issue.

Thank you for your contribution to AmplifyJS, it's greatly appreciated 😄

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.