 mooUtil = require './lib/util'
 contextBuilder = require './lib/context'
 formDescriptors = require './lib/forms'
-
-# TODO write this and put it somewhere
-sanitize = (x) -> x
 
 environment = new Mincer.Environment()
 environment.appendPath 'assets/js'


  # TODO (better) validation and sanitization
  socket.on 'form_input_create', (userData, fn) ->
    formData = sanitize userData

    formDescriptor = formDescriptors.createAccount()
    formDescriptor.inputs[0].value = formData.name
    formDescriptor.inputs[1].value = formData.username
    valid = true

    if formData.name.length < 2
      valid = false
      formDescriptor.inputs[0].error = "Not long enough"

    if db.playerNameTaken formData.name
      valid = false
      formDescriptor.inputs[0].error = "Already taken"

    if formData.username.length < 2
      valid = false
      formDescriptor.inputs[1].error = "Not long enough"

    if db.usernameTaken formData.username
      valid = false
      formDescriptor.inputs[1].error = "Already taken"

    if formData.password.length < 8
      valid = false
      formDescriptor.inputs[2].error = "Not long enough"

    if formData.password != formData.password2
      valid = false
      formDescriptor.inputs[3].error = "Doesn't match"

    if not valid
      fn formDescriptor

          socket.emit 'output', "\nUnrecognized command. Type #{c 'help', 'magenta bold'} for a list of available commands."

  socket.on 'form_input_login', (userData, fn) ->
    sanitize = (userData) ->
      username: (userData.username || "").trim()
      password: userData.password || ""

    formData = sanitize userData

    matches = db.players.filter (player) ->
