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

23 lines
640 B
JavaScript
Raw Normal View History

let express = require("express");
let router = express.Router();
let models = require("../models");
2020-08-20 14:50:59 +02:00
let userCreate = require("./utils/userCreate");
2020-08-20 22:46:46 +02:00
let reCaptcha = require("../middlewares/reCaptcha");
2020-08-20 22:46:46 +02:00
router.get("/", async (req, res) => {
if (req.session.user)
res.redirect("/");
else
2020-08-17 19:13:00 +02:00
res.render("register", {title: "SOD - register", departments: await models.Department.findAll()});
})
2020-08-20 22:46:46 +02:00
.post("/", reCaptcha, async (req, res) => {
2020-08-20 14:50:59 +02:00
let user = await userCreate(req, res);
if (user) {
2020-08-20 12:14:38 +02:00
req.session.user = user;
res.redirect("/");
}
});
module.exports = router;