     newsletter
     # is group creator already a member
     alreadyMember }              = body
-  { JUser, JGroup, JInvitation } = koding.models
   body.groupName                 = slug
   # needed for JUser.login to know that it is a regular login or group creation
   body.groupIsBeingCreated       = yes
 
   clientId                       = getClientId req, res
+
+  { JUser, JGroup, JInvitation, JTeamInvitation } = koding.models
 
   return handleClientIdNotFound res, req  unless clientId
 

      domains
      # username or email of the user, can be already registered or a new one for creation
      username
    } = body

    token = result.newToken or result.replacementToken

  alreadyMember       = alreadyMember is 'true'

  queue = [
    ->
      { teamAccessCode } = body
      # if we dont have teamaccesscode just continue
      return queue.next() if not teamAccessCode

      JTeamInvitation.byCode teamAccessCode, (err, invitation) ->
        return res.status(400).send err.message
        return res.status(400).send 'Team Invitation is not found'  if not invitation
        return res.status(400).send 'Team Invitation is not valid'  if not invitation.isValid()
        return queue.next()
    ->
      koding.fetchClient clientId, context, (client_) ->

