mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-20 12:49:32 +00:00
feat: block user creation if userCreation setting is disabled
This commit is contained in:
@@ -3,6 +3,7 @@ const Yup = require("yup");
|
|||||||
const { Op } = require("sequelize");
|
const { Op } = require("sequelize");
|
||||||
|
|
||||||
const User = require("../models/User");
|
const User = require("../models/User");
|
||||||
|
const Setting = require("../models/Setting");
|
||||||
|
|
||||||
const { getIO } = require("../libs/socket");
|
const { getIO } = require("../libs/socket");
|
||||||
|
|
||||||
@@ -55,6 +56,14 @@ exports.store = async (req, res, next) => {
|
|||||||
password: Yup.string().required().min(5),
|
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);
|
await schema.validate(req.body);
|
||||||
|
|
||||||
const io = getIO();
|
const io = getIO();
|
||||||
|
|||||||
Reference in New Issue
Block a user