 
 # index route
 app.get '/', (req, res) ->
-  res.render 'index'
+  res.render 'index', {authRequired: settings.authRequired}
 
 # authentication route
 app.post '/login', auth.authUser, (req, res) ->

  setInterval () ->
    functions.writePasses _.filter(functions.getPasses(), (p) -> p.time > new Date().getTime() - 604800000)
    functions.writeTarContents _.filter(functions.getTarContents(), (c) -> fs.existsSync(settings.downloadDir + c.filename))
    functions.writeUserNZBs _.filter(functions.getUserNZBs(), (n) -> n.time > new Date().getTime() - 604800000)
  , 86400
else
  settings.setup()


  logger.info 'user "' + req.user + '" queued "' + req.body.nzbname + '"'

  filename = sabnzbd.getTempNZBName()
  nzbname = sabnzbd.getNZBName req.body.nzbname

  fs.writeFileSync filename, req.body.nzbdata

  sabnzbd.queueNZBFile filename, nzbname, req.user, (queueRes) ->
    fs.unlink filename
    if queueRes
      sabnzbd.addUserNZB req.user, nzbname, req.body.flac2mp3
      res.json nzb: true
    else
      res.send 500
