 _                                       = require 'underscore'
+async                                   = require 'async'
 Bongo                                   = require 'bongo'
 koding                                  = require './../bongo'
 { argv }                                = require 'optimist'


{ uniq }                                = require 'underscore'
{ hostname, environment }               = KONFIG
{ dash, daisy }                         = Bongo
{ getClientId, handleClientIdNotFound } = require './../helpers'
{ validateTeamDomain }                  = require '../../../../workers/social/lib/social/models/user/validators'



  queue = [

    (next) ->
      { teamAccessCode } = body
      # if we dont have teamaccesscode just continue

      validateTeamInvitation teamAccessCode, (err) ->
        return res.status(400).send err  if err
        next()

    (next) ->
      koding.fetchClient clientId, context, (client_) ->

        client = client_
