Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async confirmSignUp() {
const { username, authCode } = this.state
await Auth.confirmSignUp(username, authCode)
.then(() => {
this.props.navigation.navigate('SignIn')
console.log('Confirm sign up successful')
})
.catch(err => {
if (! err.message) {
console.log('Error when entering confirmation code: ', err)
Alert.alert('Error when entering confirmation code: ', err)
} else {
console.log('Error when entering confirmation code: ', err.message)
Alert.alert('Error when entering confirmation code: ', err.message)
}
})
}
// Resend code if not received already
verify() {
// http://localhost:9000/verify?username=910e6571-c11e-4c83-9e27-cf220bdd6e41&code=315131
const { username, code } = queryString.parse(window.location.search);
Auth.confirmSignUp(username, code, {
// Optional. Force user confirmation irrespective of existing alias. By default set to True.
forceAliasCreation: true
}).then(data => {
console.log(data);
this.setState({ verified: true });
})
.catch(err => {
this.setState({ verified: false, error: err.code + " - " + err.message });
});
}
render() {
return dispatch => {
dispatch(loadingStart());
let email = data.email.toLowerCase().trim();
let dummyCode = "_";
Auth.confirmSignUp(email, dummyCode, {
forceAliasCreation: false
}).catch(err => {
if(err.code === "UserNotFoundException") {
dispatch(setAuthPage("signUp", "Welcome to TreeHacks! Enter the rest of your info to sign up. (Note: You must be a current undergraduate or graduate student to attend TreeHacks.)"));
dispatch(loadingEnd());
} else {
dispatch(setAuthPage("signIn", "Welcome back! Please enter your password to continue."));
dispatch(loadingEnd());
}
});
}
}
confirm() {
const username = this.usernameFromAuthData() || this.inputs.username;
const { code } = this.inputs;
if (!Auth || typeof Auth.confirmSignUp !== 'function') {
throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
}
Auth.confirmSignUp(username, code)
.then(() => this.changeState('signedUp'))
.catch(err => this.error(err));
}
onConfirm = async (event: React.FormEvent) => {
event.preventDefault();
this.setState({ loading: true });
try {
await Auth.confirmSignUp(this.state.email, this.state.confirmationCode);
await Auth.signIn(this.state.email, this.state.password);
this.props.userHasAuthenticated(true);
this.setState({ redirect: true })
} catch (e) {
alert(e.message);
this.setState({ loading: false });
}
}