Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function forgotPassword({ username }, updateFormType) {
try {
await Auth.forgotPassword(username)
updateFormType('forgotPasswordSubmit')
} catch (err) {
console.log('error submitting username to reset password...', err)
}
}
resetPassword = async () => {
try {
this.setState({ loading: true, error: '' });
const { username } = this.state;
if (username) {
const password = await Auth.forgotPassword(username);
this.setState({ loading: false, status: 'Reset confirmation pending...' });
console.log(password);
} else {
this.setState({ loading: false, error: 'Complete missing fields.' });
}
} catch (error) {
this.setState({ loading: false, error: error.message });
console.log(error.message);
}
};
onSubmit={async (values, { setSubmitting }) => {
try {
Auth.forgotPassword(values.username).then(() => {
history.push('/forgot-password-confirm');
});
setSubmitting(false);
} catch (err) {
console.log('error forgetting pass: ', err);
authError = err;
setSubmitting(false);
}
}}
>
export const forgotPassword = ({username}) => {
return Auth.forgotPassword(username).then(data => data);
}
send() {
const { username } = this.inputs;
Auth.forgotPassword(username)
.then(data => {
this.setState({ loading: false });
logger.debug(data);
this.setState({ delivery: data.CodeDeliveryDetails });
})
.catch(err => {
this.setState({ loading: false });
message.error(err.message);
});
}
sendVerificationCode = async (e) => {
e.preventDefault();
const username = this.state.username;
if (!username) {
this.setState(() => {
return {
invalidCodeOrPasswordMessage: 'Please input valid username'
}
})
}
Auth.forgotPassword(username)
.then(data => {
if (this.state.enableSend) {
this.setState(() => {
return {
enableSend: false
}
});
this.countDownResendVerificationCode();
}
if (this.state.enableResend) {
this.setState(() => {
return {
enableResend: false
}
})
this.countDownResendVerificationCode();
send() {
const { username } = this.state;
if (!username) {
this.error('Username cannot be empty');
return;
}
Auth.forgotPassword(username).then(data => {
logger.debug(data);
this.setState({ delivery: data.CodeDeliveryDetails });
}).catch(err => this.error(err));
}
send() {
const username = this.getUsernameFromInput();
if (!username) {
this.error('Username cannot be empty');
return;
}
Auth.forgotPassword(username)
.then(data => {
logger.debug(data);
this.setState({ delivery: data.CodeDeliveryDetails });
})
.catch(err => this.error(err));
}
send() {
const { username } = this.inputs;
Auth.forgotPassword(username)
.then(data => {
logger.debug(data)
this.setState({ delivery: data.CodeDeliveryDetails });
})
.catch(err => this.error(err));
}