           password: password
           password_confirmation: passwordConfirmation
 
-      registration = makeHTTPRequest 'POST', api.host + '/users', data, JSON_HEADERS, ADD_CREDENTIALS
+      makeHTTPRequest('POST', api.host + '/users', data, JSON_HEADERS, ADD_CREDENTIALS).then []...,
+        (request) ->
+          response = JSON.parse request.responseText
+          console?.log 'Created user', response
+          response
 
-      registration.then (response) ->
-        console?.log 'Created user', response
+        (error) ->
+          console?.error 'Failed to register', error
+          null
 
-      registration
-
-  checkSession: ->
-    # TODO
+  getCurrentUser: ->
+    # TODO: Check to see if anybody's signed in.
 
   signIn: ({login, password}) ->
-    @getAuthToken().then (token) ->
+    @currentUser = @getAuthToken().then (token) =>
       data =
         authenticity_token: token
         user:
           login: login
           password: password
 
-      makeHTTPRequest('POST', api.host + '/users/sign_in', data, JSON_HEADERS, ADD_CREDENTIALS).then (response) ->
-        console?.log 'Signed in', response
-        response
+      makeHTTPRequest('POST', api.host + '/users/sign_in', data, JSON_HEADERS, ADD_CREDENTIALS).then []...,
+        (request) =>
+          console?.log 'Signed in successfully as', login
+
+          # This route returns a JSON-API `users` resource.
+          api.client.processResponseTo request
+
+          Promise.all([@getBearerToken(), api.users.get {login}, 1]).then ([token, [user]]) ->
+            console?.log 'Current user', user
+            user
+
+        (error) ->
+          console?.error 'Failed to sign in', error
+          null
 
   signOut: ->
     @getAuthToken().then (token) ->
       data =
         authenticity_token: token
 
-      makeHTTPRequest('DELETE', api.host + '/users/sign_out', data, JSON_HEADERS, ADD_CREDENTIALS).then (response) ->
-        console?.log 'Signed out'
-        response
+      makeHTTPRequest('DELETE', api.host + '/users/sign_out', data, JSON_HEADERS, ADD_CREDENTIALS).then []...,
+        (request) =>
+          response = JSON.parse request.responseText
+          console?.log 'Signed out', response
+          @deleteBearerToken()
+          response
+
+        (error) ->
+          console?.log 'Failed to sign out', error
 
 module.exports = api
 window?.api = api

JSONAPIClient = require 'json-api-client'
{makeHTTPRequest} = JSONAPIClient.util

API_HOSTS =
  production: '' # Same domain!

  test: 'http://localhost:7357'
  _cam: 'http://172.17.2.87:3000'

API_APPLICATION_IDS =
  _cam: '05fd85e729327b2f71cda394d8e87e042e0b77b05e05280e8246e8bdb05d54ed'

JSON_HEADERS =
  'Accept': 'application/json'
