 
 { uniq }                                = require 'underscore'
 { hostname, environment }               = KONFIG
-{ getClientId, handleClientIdNotFound } = require './../helpers'
+{ generateAPIError
+  getClientId, handleClientIdNotFound } = require './../helpers'
 { validateTeamDomain }                  = require '../../../../workers/social/lib/social/models/user/validators'
 
 module.exports = (req, res, next) ->

        # when there is an error in the fetchClient, it returns message in it
        if client.message
          console.error JSON.stringify { req, client }
          return res.status(500).send client.message

        client.clientIP = (clientIPAddress.split ',')[0]


      # if we dont have teamaccesscode just continue

      validateTeamInvitation teamAccessCode, (err) ->
        return next generateAPIError 400, err  if err
        next()

    (next) ->
