   Token.findOne { value: value }, (err, token) ->
     cb err || !token? || token.expiration < Date.now(), token
 
-requiresToken = (func) ->
+requireToken = (func) ->
   return (req, res) ->
     _args = arguments
     _this = this

      else
        res.send { result: 'failure', provided: sha1(req.body.password) }

app.get '/user/:username', requiresToken (req, res) ->
  User.findOne { username: req.params.username }, (err, user) ->
    if err
      res.send { result: 'not found' }

app.get '/', (req, res) ->
  res.render 'index.html', { layout: false }

app.get '/categories', requireToken (req, res) ->
  Category.find {}, ['slug', 'title', 'description', '_id'], (err, cats) ->
    res.send cats

app.get '/category/:slug', requireToken (req, res) ->
  Category.findOne { slug: req.params.slug }, (err, cat) ->
    res.send cat

app.get '/thread/:tid', requireToken (req, res) ->
  Thread.findById req.params.tid, (err, thread) ->
    res.send thread

app.post '/new-thread', requireToken (req, res) ->
  thread = new Thread({ username: req.body.username, title: req.body.title })
  post = new Post({
    username: req.body.username
