{"size": 1099, "ext": "js", "max_stars_repo_path": "routes/addUser.js", "max_stars_repo_name": "wudi0431/userManger", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "routes/addUser.js", "max_issues_repo_name": "wudi0431/userManger", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "routes/addUser.js", "max_forks_repo_name": "wudi0431/userManger", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.1666666667, "max_line_length": 52, "alphanum_fraction": 0.3703366697}
var express = require('express');
var router = express.Router();
var User = require('../db/user');
var filter = require('../filter/filter');


router.post('/', function (req, res) {
    filter.authorize(req, res, function (req, res) {
        var userEntity = new User({
            name: req.body.username,
            password: req.body.password
        });
        userEntity.save(function (err, userEntity) {
            if (err) {
                res.status(500).send({
                    success: false,
                    model: {
                        error: '数据库错误'
                    }
                });
            } else {
                if (userEntity) {
                    res.status(200).send({
                        success: true
                    });
                } else {
                    res.status(200).send({
                        success: false,
                        model: {
                            error: '数据库错误'
                        }
                    });
                }
            }
        });

    });

});


module.exports = router;