amplify-js: Auth: all errors now coming back as type 'NotAuthorizedException'
Before opening, please confirm:
- I have searched for duplicate or closed issues and discussions.
- I have read the guide for submitting bug reports.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
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)
Hi @chrisbonifacio, My application was created using the react native cli, full package: