Skip to content

Instantly share code, notes, and snippets.

@amaanr
Created May 9, 2013 17:59
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 amaanr/5549266 to your computer and use it in GitHub Desktop.
Save amaanr/5549266 to your computer and use it in GitHub Desktop.
App.login = (route) ->
$.ajax
url: App.urls.login
type: "POST"
data:
"person[email]": route.currentModel.email
"person[password]": route.currentModel.password
success: (data) ->
log.log "Login Msg #{data.person.dummy_msg}"
App.currentPerson = data.person
App.LoginStateManager.transitionTo "authenticated"
route.transitionTo 'home'
error: (jqXHR, textStatus, errorThrown) ->
if jqXHR.status==401
route.controllerFor('login').set "errorMsg", "That email/password combo didn't work. Please try again"
else if jqXHR.status==406
route.controllerFor('login').set "errorMsg", "Request not acceptable (406): make sure Devise responds to JSON."
else
p "Login Error: #{jqXHR.status} | #{errorThrown}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment