Archived
1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
SOD/routes/admin/users/add.js

23 lines
772 B
JavaScript

let express = require("express");
let router = express.Router();
let sessionCheck = require("../../../middlewares/sessionCheck");
let models = require("../../../models");
let userCreate = require("../../utils/userCreate");
router.get("/", sessionCheck(3), async (req, res) => {
res.render("admin/users/add", {
title: "SOD - Users administration",
departments: await models.Department.findAll()
});
}).post("/", sessionCheck(3), async (req, res) => {
let user = await userCreate(req, res);
if (user) {
if (req.body.permissions && 0 >= req.body.permissions <= 3) {
user.permissions = req.body.permissions;
await user.save();
}
res.redirect("/admin/users");
}
});
module.exports = router;