Last active
February 27, 2020 05:55
-
-
Save LeCoupa/9878785 to your computer and use it in GitHub Desktop.
Sign up system with Meteor --> https://github.com/LeCoupa/awesome-cheatsheets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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