`Auth.confirmSignIn` throws `UserNotFoundException` upon SMS code confirm
See original GitHub issueDescribe the bug
I am attempting to implement SMS MFA with the API directly (not aws-amplify-react-native
Components). After setting up the MFA as described below, I sign out of the User, sign back in, receive the SMS code, and try to confirm it. Instead of succeeding, Auth.confirmSignIn
throws a UserNotFoundException
.
To Reproduce Steps to reproduce the behavior:
- Sign into a Cognito account that does not yet have MFA set up.
const user = await Auth.signIn(username, password);
- We have signed into the user. Our tokens are there, our account shows up in the User pool list. The user absolutely exists.
- Get 10-digit phone number from input, set up MFA with
const phone = '5553334444';
const user = await Auth.currentAuthenticatedUser();
const result = await Auth.updateUserAttributes(user, {
phone_number: `+1${phone}`,
});
await Auth.setPreferredMFA(user, 'SMS');
- Sign out
Auth.signOut();
- Sign back in
const user = await Auth.signIn(username, password);
- Ding ding ding! We get
user.challengeName === 'SMS_MFA'
. - Ring ring ring! Code shows up via SMS.
- Let’s confirm sign in.
await Auth.confirmSignIn(user, code, 'SMS_MFA');
- Boom! An error object is thrown:
Object { code: "UserNotFoundException", name: "UserNotFoundException", message: "User does not exist." }
- We are not signed in.
Expected behavior Confirm SMS code, sign into User.
Screenshots None
Smartphone (please complete the following information):
- OS: Android 8.0
- Platform:
react-native
- Versions:
react-native@0.59.5
,aws-amplify@1.1.29
Additional context Here is some Auth related configuration relevant to our user pool:
- MFA is set to Optional.
- We are using a
UserMigration
Lambda, and therefore useauthenticationFlowType: 'USER_PASSWORD_AUTH'
- The Lambda imports relevant attributes, but NOT
phone_number
andphone_number_verified
remainsfalse
throughout. - Users have
phone_number
write permissions for all App clients.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Authentication - Sign in next steps - Swift - AWS Amplify Docs
Confirm signin with SMS MFA. If the next step is confirmSignInWithSMSMFACode , Amplify Auth has sent the user a random code over SMS,...
Read more >AWS Amplify Authenticator UI confirm signin error
When I enable SMS MFA the 'AmplifyConfirmSignIn' component asks for the SMS code, but after entering the code it throws the below error....
Read more >How to use the aws-amplify.Logger function in aws ... - Snyk
Logger examples, based on popular ways it is used in public projects. ... selector: 'page-confirm-signin', templateUrl: 'confirmSignIn.html' }) export class ...
Read more >Viewing online file analysis results for 'Calm_Sleep_v0.116 ...
Submit malware for free analysis with Falcon Sandbox and Hybrid Analysis technology. Hybrid Analysis develops and licenses analysis tools to fight malware.
Read more >AuthClass | amplify-js
Initialize Auth with AWS configurations ... confirmSignIn(user: CognitoUser | any, code: string, mfaType?: ... Send MFA code to confirm sign in ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For anyone else who has this issue, I had a random user sub set as the username in my userpool, but email login.
Auth.signIn()
for anyone with MFA enabled returns an object with a username of the email, instead of the sub. I fixed this problem by explicitly setting theusername
of the signIn response to the actual username of the user, which happens to be contained withinchallengeParam.USER_ID_FOR_SRP
Essentially:
var user = await Auth.signIn(email, password);
user.username = user.challengeParam.USER_ID_FOR_SRP;
await Auth.confirmSignIn(user, code, "SMS_MFA");
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.