amplify-js: Auth: all errors now coming back as type 'NotAuthorizedException'

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Authentication

Amplify Categories

auth

Environment information

    "@aws-amplify/analytics": "^5.0.15",
    "@aws-amplify/api": "^4.0.15",
    "@aws-amplify/auth": "^4.3.5",
    "amazon-cognito-identity-js": "^5.0.5",
    "aws-amplify": "^4.2.9",
    "aws-amplify-react-native": "^5.0.3",

Describe the bug

No matter the scenario, i.e. user doesn’t exist, user not verified, password incorrect, password reset required, etc, the amplify module is now only responding with the error code ‘NotAuthorizedException’. This causes numerous problems because for one I don’t know what to do next, for two you cannot tell the user what is wrong. Up until last month, the error code gave you more details on what the error was as shown in expected behavior.

This seems to be the case for Auth.signUp and Auth.signIn

Expected behavior

Previously my app has used the following:

            if (err.code === 'UserNotConfirmedException') {
              setError('Account not verified yet');
            } else if (err.code === 'PasswordResetRequiredException') {
              setError('Existing user found. Please reset your password');
            } else if (err.code === 'NotAuthorizedException') {
              setError('Forgot Password?');
            } else if (err.code === 'UserNotFoundException') {
              setError('User does not exist!');
            } else if (err.code === 'UsernameExistsException') {
              setError('User already exists!');
            }

For example, if the user had signed up but not confirmed their email, amplify would return the error code ‘UserNotConfirmedException’ so I could tell the user to go and verify their email or request a new one.

Reproduction steps

const user = await Auth.signUp({
  username: newUsername,
  password: password,
  attributes: additionalAttr,
});

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

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

Hi @chrisbonifacio, My application was created using the react native cli, full package:

  "dependencies": {
    "@aws-amplify/analytics": "^5.0.15",
    "@aws-amplify/api": "^4.0.15",
    "@aws-amplify/auth": "^4.3.5",
    "@invertase/react-native-apple-authentication": "^1.1.2",
    "@react-native-async-storage/async-storage": "^1.15.5",
    "@react-native-community/datetimepicker": "^3.5.2",
    "@react-native-community/google-signin": "^4.0.3",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-community/netinfo": "^5.9.1",
    "@react-native-community/push-notification-ios": "^1.8.0",
    "@react-native-community/toolbar-android": "^0.1.0-rc.2",
    "@react-native-firebase/analytics": "^10.8.1",
    "@react-native-firebase/app": "10.8.1",
    "@react-native-firebase/messaging": "10.8.1",
    "@react-navigation/bottom-tabs": "5.11.11",
    "@react-navigation/native": "5.9.4",
    "@react-navigation/stack": "5.14.5",
    "amazon-cognito-identity-js": "^5.0.5",
    "aws-amplify": "^4.2.9",
    "aws-amplify-react-native": "^5.0.3",
    "crypto-js": "3.3.0",
    "fuse.js": "^6.4.0",
    "fuzzy": "^0.1.3",
    "fuzzy-search": "^3.2.1",
    "moment": "^2.24.0",
    "prop-types": "^15.7.2",
    "react": "16.13.1",
    "react-native": "0.63.3",
    "react-native-app-intro-slider": "^4.0.4",
    "react-native-background-timer": "2.2.0",
    "react-native-calendars": "^1.1129.0",
    "react-native-camera": "^3.26.0",
    "react-native-collapsible": "^1.5.2",
    "react-native-config": "^1.2.0",
    "react-native-deep-linking": "^2.2.0",
    "react-native-dialog": "^5.6.0",
    "react-native-elements": "^2.0.0",
    "react-native-fast-image": "^8.1.5",
    "react-native-fbsdk": "^2.0.0",
    "react-native-floating-action": "https://github.com/ramonvermeulen/react-native-floating-action.git#fixForNativeDriverWarning",
    "react-native-floating-label": "^0.2.3",
    "react-native-gesture-handler": "^1.6.1",
    "react-native-inappbrowser-reborn": "^3.6.3",
    "react-native-iphone-x-helper": "^1.2.1",
    "react-native-keychain": "^6.0.0",
    "react-native-markdown-display": "^7.0.0-alpha.2",
    "react-native-modal-datetime-picker": "^10.2.0",
    "react-native-modest-checkbox": "^3.3.0",
    "react-native-popup-menu": "^0.15.7",
    "react-native-push-notification": "^7.4.0",
    "react-native-reanimated": "^1.9.0",
    "react-native-safe-area-context": "^3.2.0",
    "react-native-screens": "^2.8.0",
    "react-native-share": "^3.3.2",
    "react-native-side-drawer": "^1.2.6",
    "react-native-simple-toast": "^1.1.2",
    "react-native-size-matters": "^0.4.0",
    "react-native-snap-carousel": "3.9.1",
    "react-native-spinkit": "^1.5.0",
    "react-native-splash-screen": "^3.2.0",
    "react-native-svg": "^12.1.0",
    "react-native-svg-transformer": "^0.14.3",
    "react-native-tab-view": "^2.14.2",
    "react-native-vector-icons": "^6.6.0",
    "react-native-view-shot": "^3.1.2",
    "react-native-walkthrough-tooltip": "^1.1.9",
    "react-redux": "^7.2.0",
    "redux": "^4.0.5",
    "redux-persist": "^6.0.0",
    "redux-saga": "^1.1.3",
    "redux-thunk": "^2.3.0",
    "tcomb-form-native": "^0.6.20",
    "url-parse": "^1.4.7"
  },
  "devDependencies": {
    "@babel/core": "^7.8.4",
    "@babel/runtime": "^7.8.4",
    "@react-native-community/eslint-config": "^1.1.0",
    "babel-jest": "^25.1.0",
    "eslint": "^6.8.0",
    "jest": "^26.0.1",
    "metro-react-native-babel-preset": "^0.59.0",
    "react-native-linear-gradient": "^2.5.6",
    "react-test-renderer": "16.13.1"
  },