feat: block user creation if userCreation setting is disabled

This commit is contained in:
canove
2020-09-04 10:56:47 -03:00
parent e4e918ab90
commit 364b94c8ab

View File

@@ -3,6 +3,7 @@ const Yup = require("yup");
const { Op } = require("sequelize");
const User = require("../models/User");
const Setting = require("../models/Setting");
const { getIO } = require("../libs/socket");
@@ -55,6 +56,14 @@ exports.store = async (req, res, next) => {
password: Yup.string().required().min(5),
});
const { value: userCreation } = await Setting.findByPk("userCreation");
if (userCreation === "disabled") {
return res
.status(403)
.json({ error: "User creation is disabled by administrator" });
}
await schema.validate(req.body);
const io = getIO();