 
 # Default options
 opts =
-  SECURE_ARENA_URL: 'http://api.are.na'
+  SECURE_ARENA_URL: 'https://secure.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']

#
serializeUser = (user, done) ->
  user.fetch
    success: ->
      keys = ['accessToken'].concat opts.userKeys
      done null, user.pick(keys)
    error: (m, e) -> done e.text

deserializeUser = (userData, done) ->
  done null, new opts.CurrentUser(userData)

  if req.user
    res.locals.user = req.user
    res.locals.sd?.CURRENT_USER = req.user.toJSON()
  next()

headerLogin = (req, res, next) ->
  return next() if req.path is opts.logoutPath
  if token = req.get('X-AUTH-TOKEN') or req.query.access_token
    req.login new opts.CurrentUser(access_token: token), next
  else
    next()

