 { daisy }                          = require 'bongo'
 { checkAuthorizationBearerHeader } = require '../../helpers'
 { sendApiError
+  verifyApiToken
   sendApiResponse
   checkApiAvailability }           = require './helpers'
 


module.exports = createSsoToken = (req, res, next) ->

  { JAccount, JGroup, JUser, JApiToken } = (require '../../bongo').models

  # validating req params
  { error, token, username } = validateRequest req

  queue = [

    ->
      verifyApiToken token, (err, apiToken_) ->
        return sendApiError res, err  if err

        apiToken = apiToken_
        queue.next()

    ->
