Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async completeNewPassword(event) {
if (event) {
event.preventDefault();
}
if (!Auth || typeof Auth.completeNewPassword !== 'function') {
throw new Error(NO_AUTH_MODULE_FOUND);
}
try {
const { requiredAttributes } = this.user.challengeParam;
const user = await Auth.completeNewPassword(this.user, this.password, requiredAttributes);
user.challengeParameter;
logger.debug('complete new password', user);
switch (user.challengeName) {
case ChallengeName.SMSMFA:
this.handleAuthStateChange(AuthState.ConfirmSignIn, user);
break;
case ChallengeName.MFASetup:
logger.debug('TOTP setup', user.challengeParam);
this.handleAuthStateChange(AuthState.TOTPSetup, user);
break;
default:
this.checkContact(user);
}
} catch (error) {
logger.error(error);