Created
October 18, 2012 19:08
-
-
Save elbuo8/3914143 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
submitForm: (e) -> | |
e.preventDefault() | |
# Reset everything | |
containsEmail = false | |
containsPassword = false | |
shortPassword = false | |
notValidEmail = false | |
email = @$el.find('[name="email"]').val() | |
password = @$el.find('[name="password"]').val() | |
if password.length < 6 | |
console.log "short" | |
shortPassword = true | |
@render() | |
return | |
_user = new User() | |
_user.set('username', email) | |
_user.set('password', password) | |
_user.set('email', email) | |
_user.signUp null, | |
success: (user) -> | |
application.user = user | |
application.router.navigate 'new', trigger: true | |
error: (user, error) => | |
if error.code == 125 | |
notValidEmail = true | |
@render() | |
# Name exists, try to logIn | |
if error.code == 202 | |
Parse.User.logIn email, password, | |
success: (user) -> | |
application.user = user | |
#console.log application.user | |
application.router.navigate 'new', trigger: true | |
error: (user, error) -> | |
console.log 'Bad email/password' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment