I am updating password using auth.completeNewPassword()
. When I try to update the password. I get this error.
TypeError: user.completeNewPasswordChallenge is not a function
at Auth.js:865
at new ZoneAwarePromise (zone-evergreen.js:960)
at AuthClass.push../node_modules/@aws-amplify/auth/lib-esm/Auth.js.AuthClass.completeNewPassword (Auth.js:864)
at AuthenticationService.updatePassword (authentication.service.ts:68)
at CompletePasswordComponent.onSubmit (complete-password.component.ts:30)
at CompletePasswordComponent_Template_form_ngSubmit_1_listener (complete-password.component.html:2)
at executeListenerWithErrorHandling (core.js:21806)
at wrapListenerIn_markDirtyAndPreventDefault (core.js:21848)
at SafeSubscriber.schedulerFn [as _next] (core.js:37171)
at SafeSubscriber.__tryOrUnsub (Subscriber.js:183)
Here is the code I am using:
Auth.completeNewPassword(user, password, []).then((data) => {
console.log(data);
})
.catch((err) => console.log(err));
To pass the first parameter(user), I am storing cognito user in local storage and retrieving when I need to use this method.
I managed to solve this issue using RxJS BehaviorSubject.
I answered this question here.