Skip to content

Instantly share code, notes, and snippets.

@LeCoupa
Last active February 27, 2020 05:55
Show Gist options
  • Save LeCoupa/9878785 to your computer and use it in GitHub Desktop.
Save LeCoupa/9878785 to your computer and use it in GitHub Desktop.
<template name="SignUp">
<form action="/sign-up" id="signUpForm" method="post">
<input id="signUpEmail" name="email" placeholder="Email Address" type="text" >
<input id="signUpPassword" name="password" placeholder="Password" type="password">
<input id="signUpPasswordConfirm" name="password-confirm" placeholder="Confirm" type="password">
<input class="btn-submit" type="submit" value="Join Meteorites!">
</form>
<!-- end #sign-up-form -->
</template>
Template.SignUp.events({
'submit #signUpForm': function(e, t) {
e.preventDefault();
var signUpForm = $(e.currentTarget),
email = trimInput(signUpForm.find('#signUpEmail').val().toLowerCase()),
password = signUpForm.find('#signUpPassword').val(),
passwordConfirm = signUpForm.find('#signUpPasswordConfirm').val();
if (isNotEmpty(email) && isNotEmpty(password) && isEmail(email) && areValidPasswords(password, passwordConfirm)) {
Accounts.createUser({email: email, password: password}, function(err) {
if (err) {
if (err.message === 'Email already exists. [403]') {
console.log('We are sorry but this email is already used.');
} else {
console.log('We are sorry but something went wrong.');
}
} else {
console.log('Congrats new Meteorite, you\'re in!');
}
});
}
return false;
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment