Skip to content

Instantly share code, notes, and snippets.

@elbuo8
Created October 18, 2012 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elbuo8/3914143 to your computer and use it in GitHub Desktop.
Save elbuo8/3914143 to your computer and use it in GitHub Desktop.
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