{"size": 809, "ext": "js", "max_stars_repo_path": "functions/controllers/users/users-controller.js", "max_stars_repo_name": "tnanhekhan/vocab", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "functions/controllers/users/users-controller.js", "max_issues_repo_name": "tnanhekhan/vocab", "max_issues_repo_issues_event_min_datetime": "2020-05-19T17:13:07.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-22T12:13:33.000Z", "max_forks_repo_path": "functions/controllers/users/users-controller.js", "max_forks_repo_name": "tnanhekhan/vocab", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 5, "max_forks_count": null, "avg_line_length": 25.28125, "max_line_length": 83, "alphanum_fraction": 0.4956736712}
const repo = require("../../data/users/users-repository");

exports.getUsers = (req, res) => {
    repo.getUsers(req)
        .then(users => {
            res.render("users/users", {title: "CMS", dest: "users", users: users});
        });
}

exports.deleteUser = (req, res) => {
    repo.deleteUser(req.body.uid)
        .then(() => {
            res.redirect("/cms/users");
        })
        .catch(() => {
            res.redirect("/cms/users");
        });
}

exports.getAddUser = (req, res) => {
    res.render("users/add-user", {title: "CMS", dest: "users"});
}

exports.createUser = (req, res) => {
    repo.createUser(req.body.user, req.body.pass)
        .then(user => {
            res.redirect("/cms/users");
        })
        .catch(error => {
            res.redirect("/cms/users");
        })
}