We have an application using AWS Cognito (+ hosted web UI) where users are only created by administrators. MFA with SMS is required. This is our current flow for new users:
- Admin creates a new user using
AdminCreateUser
of aws-sdk. Email, name and phone number are given. - A new account is created with
FORCE_CHANGE_PASSWORD
status. Username and a temporary password are sent to the user via email. - User signs in for the first time with the temporary password.
- Cognito asks for a new password.
- User sets their new password and proceeds to log in.
- MFA code is sent to user via SMS. However, Cognito does not ask for the MFA code. User simply gets logged in. Account status is now
CONFIRMED
butphone_number_verified
is not set.
However, the MFA challenge works fine starting from the second login. In other words, user's phone number only gets verified if they manage to log in for the second time. This means that a user who forgets their password after the initial login is unable to reset their password (as it requires a verified phone number).
Any idea why this is happening and what settings should I look into? I'm aware I can avoid the main problem by programmatically setting phone_number_verified
as true
, but I'd like to know why the MFA challenge fails on first login.