Allow/deny users to register

This commit is contained in:
xfarrow 2023-10-16 14:59:46 +02:00
parent dd43439d5b
commit 827f6399e9
2 changed files with 7 additions and 2 deletions

View File

@ -10,4 +10,4 @@ POSTGRES_PASSWORD = postgres
POSTGRES_PORT = 5432
# Application settings
ALLOW_USER_REGISTRATION = true
ALLOW_USER_REGISTRATION = false

View File

@ -31,6 +31,10 @@ const jwt = require('jsonwebtoken');
// POST
async function registerPerson(req, res){
if (process.env.ALLOW_USER_REGISTRATION === 'false'){
return res.status(403).json({error : "Users cannot register on this server"});
}
// Ensure that the required fields are present before proceeding
if (!req.body.display_name || !req.body.email || !req.body.password) {
return res.status(400).json("Invalid request.");
@ -54,7 +58,8 @@ async function registerPerson(req, res){
date_of_birth: req.body.date_of_birth,
available: req.body.available,
enabled: true,
place_of_living: req.body.place_of_living})
place_of_living: req.body.place_of_living
})
.returning("id");
await tr('ActivationLink')