Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async forgotPasswordSubmit() {
const { username, authCode, newPassword } = this.state
await Auth.forgotPasswordSubmit(username, authCode, newPassword)
.then(() => {
this.props.navigation.navigate('SignIn')
console.log('the New password submitted successfully')
})
.catch(err => {
if (! err.message) {
console.log('Error while confirming the new password: ', err)
Alert.alert('Error while confirming the new password: ', err)
} else {
console.log('Error while confirming the new password: ', err.message)
Alert.alert('Error while confirming the new password: ', err.message)
}
})
}
render() {
return dispatch => {
if (data.password !== data.password2) {
dispatch(onAuthError("Passwords do not match."));
return;
}
dispatch(loadingStart());
Auth.forgotPasswordSubmit(data.email.toLowerCase(), data.code, data.password)
.then(() => dispatch(setAuthPage("signIn", "Password changed successfully! Please log in with your new password:")))
.catch(e => dispatch(onAuthError(e.message)))
.then(() => dispatch(loadingEnd()))
}
}
submit() {
const { authData = {} } = this.props;
const { code, password } = this.inputs;
const username = this.getUsernameFromInput() || authData.username;
if (!Auth || typeof Auth.forgotPasswordSubmit !== 'function') {
throw new Error(
'No Auth module found, please ensure @aws-amplify/auth is imported'
);
}
Auth.forgotPasswordSubmit(username, code, password)
.then(data => {
logger.debug(data);
this.changeState('signIn');
this.setState({ delivery: null });
})
.catch(err => this.error(err));
}