 #
 serializeUser = (user, done) ->
   user.fetch
+    data:
+      auth_token: user.get('access_token')
     success: ->
-      keys = ['accessToken'].concat opts.userKeys
+      keys = ['access_token'].concat opts.userKeys
       done null, user.pick(keys)
-    error: (m, e) -> done e.text
+    error: (m, e) ->
+      done e.text
 
 deserializeUser = (userData, done) ->
   done null, new opts.CurrentUser(userData)


# Default options
opts =
  SECURE_ARENA_URL: 'http://api.are.na'
  loginPath: '/me/sign_in'
  signupPath: '/me/invitation/accept'
  userKeys: ['id', 'first_name', 'last_name', 'email', 'slug', 'following_ids', 'notification_count', 'username', 'authentication_token']

initPassport = ->
  passport.serializeUser serializeUser
  passport.deserializeUser deserializeUser
  passport.use new LocalStrategy(
    { usernameField: 'email', passReqToCallback: true }
    arenaCallback
  )

#
# Passport callbacks
#
arenaCallback = (req, username, password, done) ->
  request.post("#{opts.SECURE_ARENA_URL}/tokens").query(
    email: username
    password: password
