Last active
February 27, 2020 05:52
-
-
Save LeCoupa/9878876 to your computer and use it in GitHub Desktop.
Sign in 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="SignIn"> | |
<form action="/signin" id="signInForm" method="post"> | |
<input id="signInEmail" type="text" name="email" placeholder="Email Address"> | |
<input id="signInPassword" type="password" name="password" placeholder="Password"> | |
<input class="btn-submit" type="submit" value="Sign In"> | |
</form> | |
<!-- end #sign-in-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.SignIn.events({ | |
'submit #signInForm': function(e, t) { | |
e.preventDefault(); | |
var signInForm = $(e.currentTarget), | |
email = trimInput(signInForm.find('.email').val().toLowerCase()), | |
password = signInForm.find('.password').val(); | |
if (isNotEmpty(email) && isEmail(email) && isNotEmpty(password) && isValidPassword(password)) { | |
Meteor.loginWithPassword(email, password, function(err) { | |
if (err) { | |
console.log('These credentials are not valid.'); | |
} else { | |
console.log('Welcome back Meteorite!'); | |
} | |
}); | |
} | |
return false; | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment