I am using Amplify and creating a forgotten password journey for my app. I am using this function:
import { Auth } from 'aws-amplify';
// Send confirmation code to user's email
Auth.forgotPassword(username)
.then(data => console.log(data))
.catch(err => console.log(err));
// Collect confirmation code and new password, then
Auth.forgotPasswordSubmit(username, code, new_password)
.then(data => console.log(data))
.catch(err => console.log(err));
As specified in the docs here
What I want to achieve is a 3 page journey.
- enter email address
- enter code (and have it validated before moving on to the next page)
- enter new password
The issue that I am having is that the provided forgotPasswordSubmit function takes all 3 args, when at this point, I only want to send 2 (email and code).
My plan was to send the email, and the code, and an empty string for the password, and then check the returned errors to see if there was one relating to the code being incorrect however I only ever get an error for the password being invalid.
Is there a way that I can get amplify to send back all errors at once (in this case the password being invalid but ALSO the code not being correct), or is there a nicer way of doing this?
I have searched for ages for an answer before asking here so any help would be much appreciated.
3
Answers
I believe you can only do it as a two stage process.
I have exactly the same problem. In our website, the forgotPassword flow looks like this:
request a verification code -> verify code -> input new password
But with the AWS amplify methods, I can ONLY do the step 2nd and 3rd TOGETHER.
Hope if there is a way to solve this problem.
I figured about a way to get around this problem. It’s definitely not ideal, but it works!