   queue = [
 
     ->
-      validateData { token, username }, (err, data) ->
+      validateData { token, username, suggestedUsername }, (err, data) ->
         return sendApiError res, err  if err
         { username, apiToken } = data
         queue.next()

  checkAuthorizationBearerHeader } = require '../../helpers'
{ sendApiError
  sendApiResponse
  checkApiTokenAvailability }       = require './helpers'


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

        queue.next()

    ->
      # if username is not provided and suggestedUsername is too long return error
      unless username
        unless isSuggestedUsernameLengthValid suggestedUsername
          return callback apiErrors.outOfRangeSuggestedUsername

      # if username is not set generate a username by suggestedUsername with a suffix
      username or= "#{suggestedUsername}#{hat(32)}"

      # checking if username has valid length
      unless isUsernameLengthValid username
        return callback apiErrors.outOfRangeUsername

      # checking if username is available
      JUser.usernameAvailable username, (err, { kodingUser, forbidden }) ->
        return callback apiErrors.internalError          if err
