all. Can anyone help me understand why I am getting a Uncaught (in promise) TypeError: callback is undefined in the below code? It does not make it to the on success or on failure clauses.
const onSubmitPasscode = (event) => {
event.preventDefault();
if (passwordFirst !== passwordSecond) {
alert('the two inputs provided are not the same');
} else {
const user = new CognitoUser({
Username: email,
Pool: UserPool
});
const authDetails = new AuthenticationDetails({
Username: email,
Password: password
});
user.authenticateUser(authDetails, {
onFailure: (err) => {
console.error('onFailure:', err);
},
newPasswordRequired: () => {
user.completeNewPasswordChallenge(passwordFirst, {
onFailure: (err) => {
console.error('onFailure:', err);
},
onSuccess: (result) => {
console.log(passwordFirst);
console.log('call result: ', result);
navigate('dashboard');
}
});
}
});
}
Define an
onSuccess
function forauthenticateUser
:Also, based on the documentation,
newPasswordRequired
takes a function whose signature is different from what you are providing. So I think what you might want is really: