challengeName not present after using verifyTotpToken
See original GitHub issueThe problem does not occur when using the aws-amplify-react components but I’m trying to create a custom component for TOTP setup and it doesn’t seem to work correctly.
The following code works without an error
const verifyTotpToken = async ({ totpCode }) => {
if (
!Auth ||
typeof Auth.verifyTotpToken !== 'function' ||
typeof Auth.setPreferredMFA !== 'function'
) {
throw new Error(
'No Auth module found, please ensure @aws-amplify/auth is imported'
);
}
const user = authData;
console.log('verifyTotpToken, user', user);
try {
await Auth.verifyTotpToken(user, totpCode);
try {
await Auth.setPreferredMFA(user, 'TOTP');
setSetupMessage('Setup successfully!');
logger.debug('set up totp success!');
triggerTOTPEvent('Setup TOTP', 'SUCCESS', user);
} catch (err) {
console.log('setPreferredMFA error', err);
setError('Setup failed!');
}
} catch (err) {
console.log('setup error', err);
setError('Setup failed!');
logger.error(err);
}
};
and results in preferredMFA
being set to SOFTWARE_TOKEN_MFA
but on signing in there is no challengeName
so the user is never asked to enter a code.
If I then try await Auth.setPreferredMFA(authData, 'TOTP')
after this I get an error of User has not verified software token mfa
I can’t see why this is not working as it’s not much different to how aws-amplify-react components work.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
React & AWS Amplify - User does not have delivery config set ...
challengeName ) { await Auth.verifyTotpToken(userObject, mfaToken); // This would be step 6 in the CLI version above. await Auth.
Read more >AuthClass | amplify-js
Refer to the documentation for how to setup and use MFA: ... verifyTotpToken(user: CognitoUser | any, challengeAnswer: string): Promise<CognitoUserSession>.
Read more >Multi-factor authentication - JavaScript - AWS Amplify Docs
With TOTP (Time-based One-time Password), your app user is challenged to complete authentication using a time-based one-time (TOTP) password after their ...
Read more >Soft-Token Authentication with AWS Amplify, Cognito and ...
A significant gotcha is presented here, note the line: Auth.enableSMS(props.user);. I realised that unless smsMFA is enabled then the workflow ...
Read more >How to use the aws-amplify.Auth function in aws-amplify - Snyk
Use Snyk Code to scan source code in minutes - no build needed - and fix ... verifyTotpToken(user, totpCode).then(function () { // set...
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
SOLUTION I was having the same issue but fixed it by running Auth.currentAuthenticatedUser after Auth.setPreferredMFA finished. Next time the user logs in they should have an auth challenge. The flow goes something like this: setupTOTP -> verifyTotpToken -> setPreferredMFA -> currentAuthenticatedUser -> signOut -> signIn
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.