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/register.js
2020-08-21 11:11:36 +02:00

22 lines
640 B
JavaScript

let express = require("express");
let router = express.Router();
let models = require("../models");
let userCreate = require("./utils/userCreate");
let reCaptcha = require("../middlewares/reCaptcha");
router.get("/", async (req, res) => {
if (req.session.user)
res.redirect("/");
else
res.render("register", {title: "SOD - register", departments: await models.Department.findAll()});
})
.post("/", reCaptcha, async (req, res) => {
let user = await userCreate(req, res);
if (user) {
req.session.user = user;
res.redirect("/");
}
});
module.exports = router;