Auth: signIn always returns { challengeName : "NEW_PASSWORD_REQUIRED" }
See original GitHub issueDescribe the bug
The Auth.signIn()
function always returns a new password challenge in the user object:
{ challengeName : "NEW_PASSWORD_REQUIRED" }
, even after doing Auth.completeNewPassword()
The user status is “CONFIRMED” in the AWS Cognito user list.
To Reproduce Steps to reproduce the behavior:
- Create a new user
- Start sign in flow:
signIn(username, password )
.then(user => {
if ((user.challengeName == 'NEW_PASSWORD_REQUIRED')) {
this._setCompletePasswordState(user);
} else {
this.props.onSignIn(user);
}
})
- Start complete password flow:
completeNewPassword(params)
.then(response => {
console.log('password changed: ', response);
this.props.onSignIn();
})
- Log out
- Log back in and inspect user payload
Expected behavior I think the challengeName should be empty
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: macOS
- Browser: Chrome
- Version: 68
Additional context
I am currently getting around this by running checkCurrentAuth()
after signIn()
and using a catch to detect if the user needs to reset their password:
signIn({ username, password })
.then(user => {
checkCurrentAuth()
.then(() => {
this.props.onSignIn(user);
})
.catch(() => {
this._setCompletePasswordState(user);
});
})
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
How to process with AWS-cognito ...
You can use the respondToAuthChallenge method to set the user's new password and log them in. It should also return the accessToken for...
Read more >RespondToAuthChallenge - Amazon Cognito User Pools
The result returned by the server in response to the request to respond to the authentication challenge. Type: AuthenticationResultType object. ChallengeName.
Read more >Overcoming shortfalls of AWS Cognito Part1 – Email OTP
This gets called once define auth lambda returns challenge name as ... throw a NEW_PASSWORD_REQUIRED challenge for the first-time login.
Read more >initiate-auth — AWS CLI 2.9.6 Command Reference
You can't sign in a user with a federated IdP with InitiateAuth . ... REFRESH_TOKEN_AUTH takes in a valid refresh token and returns...
Read more >Application Authentication Using Amazon Cognito and An ...
Typically, the user authentication requirements for an application can be largely classified in ... ChallengeName='NEW_PASSWORD_REQUIRED',.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You appear to be asigning the value to user.challengeName instead of reading it.
I think
if (user.challengeName = 'NEW_PASSWORD_REQUIRED')
should beif (user.challengeName === 'NEW_PASSWORD_REQUIRED')
?See: https://aws-amplify.github.io/docs/js/authentication#complete-new-password
This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server
*-help
channels or Discussions for those types of questions.