amplify-js: Cannot sign in after calling Auth.completeNewPassword
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Call to Auth.completeNewPassword catches error “signin failed” with no other information. Subsequent signin attempt calling Auth.signin catches error “signin failed” with no other information.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn’t have dependencies other than AWS Amplify.
Steps:
- Created user in my AWS user pool with temp password.
- Used the username and password on the LoginPage.
- Stored the User object returned on Redux reducer state.
- Route transition to the ChangePassword component when the challengeName is ‘NEW_PASSWORD_REQUIRED’ .
- Get User object off of the Redux reducer state.
- Call the Auth.completeNewPassword with userObject, new user password and user object challengeParam required attributes.
- Request succeeds with Access Token.
- Check the user status in the AWS user pool. Status is changed from FORCE_CHANGE_PASSWORD to CONFIRMED but signin fails.
Imports for my login page component.
import Amplify, { Auth } from 'aws-amplify';
import awsConfig from './aws-exports.js';
import { setSessionDetails } from './sessionActions.js';
Amplify.configure(awsConfig);
This is the submit callback function in my LoginPage component.
_onSubmit() {
const { dispatch } = this.props;
Auth.signIn(this._userName.value, this._password.value)
.then(loginInfo => {
console.log(loginInfo);
if (loginInfo.challengeName === 'NEW_PASSWORD_REQUIRED') {
dispatch(
setSessionDetails({
userObject: loginInfo,
})
);
this.props.history.push('./changePassword');
} else {
dispatch(
setSessionDetails({
sessionToken: loginInfo.Session,
userName: loginInfo.username,
userObject: loginInfo,
isAuthenticated: true,
})
);
}
})
.catch(err => console.error(err));
}
This is the submit callback function in my ChangePassword component.
_onSubmit() {
const { dispatch } = this.props;
const { userObject } = this.props.sessionReducer;
if (this._passwordConfirm.value === this._password.value) {
Auth.completeNewPassword(
userObject,
this._password.value,
userObject.challengeParam.requiredAttributes
)
.then(user => {
console.log(user);
})
.catch(err => console.log(err));
}
}
What is the expected behavior?
Expect sign in to succeed after password change.
Which versions of Amplify, and which browser / OS are affected by this issue? Did this work in previous versions?
“aws-amplify”: “0.2.14” Browser: Google Chrome Version 65.0.3325.181
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (6 by maintainers)
This issue occurs from Amplify version 0.2.12 onwards. Downgrading back to 0.2.11 resolves it for now.