text: // Generated by CoffeeScript 1.7.1
  (function() {
    var config, express, router, _;
  
    express = require('express');
  
    _ = require('underscore');
  
    config = require('../config');
  
    router = express.Router();
  
    router.get('/', function(req, res) {
      return res.render('login');
    });
  
    router.post('/', function(req, res) {
      var password, state, username, _ref;
      state = req.query.state;
      _ref = req.body, username = _ref.username, password = _ref.password;
      if (username === 'root' && password === config.rootSecret) {
        req.session.user = {
          username: username,
          admin: true
        };
        if (state) {
          return res.redirect(state);
        }
        return res.redirect('../');
      } else {
        return res.render('login', {
          err: '用户名或密码错误'
        });
      }
    });
  
    module.exports = router;
  
  }).call(this);
  