如何使用 Amplify 返回该特定用户的状态?我this.state.email
有为用户。
这是我的 handleSubmit 函数的样子:
handleSubmit = async event => {
event.preventDefault();
this.setState({ isLoading: true });
try {
const newUser = await Auth.signUp({
username: this.state.email,
password: this.state.password,
});
this.setState({ newUser });
} catch (e) {
if (e.name === 'UserNotConfirmedException') {
alert(
'Looks like your account isn\'t confirmed! ' +
'Please check your email to find the confirmation code.',
);
// await Auth.resendSignUp(this.state.email);
this.setState({
newUser: {
username: this.state.email,
password: this.state.password,
},
});
} else if (e.name === 'UsernameExistsException') {
// how to check if unconfirmed?
if ('not sure what to put here') {
alert(
'Looks like your account isn\'t confirmed! ' +
'Please check your email to find the confirmation code.',
);
// bring up confirmation page
} else {
alert(
'Looks like you already have an account! ' +
'Please log in with your current password.',
);
this.props.history.push('/login');
}
} else {
alert(e.message);
}
}
this.setState({ isLoading: false });
}
有任何想法吗?