backend: add DISABLE_ACCOUNT_CREATION env
This commit is contained in:
parent
92ce055dd7
commit
97fa63199e
2 changed files with 6 additions and 1 deletions
|
@ -4,7 +4,8 @@ export const errors = {
|
|||
BAD_AUTH: { code: 6003, message: "Bad authentication" },
|
||||
NOT_FOUND: { code: 6004, message: "Not found" },
|
||||
FORBIDDEN_DUE_TO_MISSING_PERMISSIONS: { code: 6005, message: "Forbidden due to missing permission(s)" },
|
||||
GOT_NO_DATABASE_DATA: { code: 7001, message: "Unexpectedly got no data from database" }
|
||||
GOT_NO_DATABASE_DATA: { code: 7001, message: "Unexpectedly got no data from database" },
|
||||
FEATURE_DISABLED: { code: 7002, message: "This feature is disabled" }
|
||||
};
|
||||
|
||||
export const gatewayErrors = {
|
||||
|
|
|
@ -12,6 +12,10 @@ router.post(
|
|||
body("username").isLength({ min: 3, max: 32 }).isAlphanumeric("en-US", { ignore: " _-" }),
|
||||
body("password").isLength({ min: 8, max: 1000 }),
|
||||
async (req, res) => {
|
||||
if (process.env.DISABLE_ACCOUNT_CREATION === "true") {
|
||||
return res.status(403).json({ ...errors.FEATURE_DISABLED });
|
||||
}
|
||||
|
||||
const validationErrors = validationResult(req);
|
||||
if (!validationErrors.isEmpty()) {
|
||||
return res.status(400).json({ ...errors.INVALID_DATA, errors: validationErrors.array() });
|
||||
|
|
Loading…
Reference in a new issue