           type: 'POST'
           url: @loginPath
           data: { assertion: assertion }
-          success: @onLogin
-          error: @onLoginError
+          success: (data, status, xhr) => @onLogin(data, status, xhr)
+          error: (xhr, status, err) => @onLoginError(xhr, status, err)
       onlogout: =>
         $.ajax
           type: 'POST'
           url: @logoutPath
-          success: @onLogout
-          error: @onLogoutError
+          success: (data, status, xhr) => @onLogout(data, status, xhr)
+          error: (xhr, status, err) => @onLogoutError(xhr, status, err)
 
 
 

# BrowserID javascript functions

@browserid = browserid =
  # Public: Path used to verify browserID authentication assertions. Assertions
  # are POSTed to this path.
  loginPath: '/login'

  # This should clear the currently-logged-in user email.
  logoutPath: '/logout'

  # Internal: Debugging toggle - if true, the results of logins will be alert
  # dialogs instead of page refreshes. This is useful to set if the application
  # starts going into a refresh loop.
  debug: false



  ### HANDLERS ###

  # Public: This method is called when a user successfully authenticates. By
  # default, it reloads the current page.
  onLogin: (data, status, xhr) ->
    if @debug
      alert("Login result: #{status} #{data}")
    else
      window.location.reload()

  # Public: This method is called when a user fails to authenticate.
  onLoginError: (xhr, status, err) ->
