Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
signUp () {
const { email, password, role } = this.inputs;
this.setState({ loading: true, error: false });
Auth.signUp({
username: email,
password,
attributes: {
email,
"custom:role": role
}
})
// Auth.signUp(username, password, email, phone_number)
.then(data => {
this.setState({ loading: false });
this.changeState("confirmSignUp", data);
})
.catch(err => {
this.setState({ loading: false, error: err.message });
message.error(err.message);
});
signUp = async () => {
this.setState({ loading: true, error: '' });
const {
username, password, email, phone_number,
} = this.state;
if (username && password && email && phone_number) {
await Auth.signUp({
username,
password,
attributes: {
phone_number,
email,
},
})
.then((data) => {
this.setState({ loading: false, status: 'User confirmation pending...' });
console.log(data);
})
.catch((error) => {
this.setState({ loading: false, error: error.message });
});
} else {
this.setState({ loading: false, error: 'Complete missing fields.' });
signUp = async () => {
const {
username, password, email, phone_number
} = this.state
try {
await Auth.signUp({ username, password, attributes: { email, phone_number }})
console.log('successful sign up..')
this.setState({ stage: 1 })
} catch (err) {
console.log('error signing up...', err)
}
}
confirmSignUp = async () => {
async function handleSubmit(event) {
event.preventDefault();
setIsLoading(true);
try {
const newUser = await Auth.signUp({
username: fields.email,
password: fields.password
});
setIsLoading(false);
setNewUser(newUser);
} catch (e) {
alert(e.message);
setIsLoading(false);
}
}
signUp = async() => {
const { username, password, email, phone_number } = this.state
try {
await Auth.signUp({ username, password, attributes: { email, phone_number }})
this.setState({ stage: 1 })
} catch (err) {
this.setState({ error: err })
console.log('error signing up...', err)
}
}
return dispatch => {
dispatch(createUser());
return Auth.signUp(data)
.then(res => {
dispatch(createUserSuccess(res));
Actions.navigate('SignIn');
})
.catch(err => {
dispatch(createUserError(err));
});
};
}