add toggle for allowing registrations from the frontend

This commit is contained in:
2025-08-10 13:36:07 +01:00
parent b790b3bd76
commit a53c50b8b4
4 changed files with 294 additions and 3 deletions

View File

@@ -6,6 +6,14 @@ const User = require('../models/User');
// Register new user
router.post('/register', async (req, res) => {
try {
// Check if registration is enabled
const registrationEnabled = process.env.ALLOW_REGISTRATION !== 'false';
if (!registrationEnabled) {
return res.status(403).json({
error: 'Registration is currently disabled'
});
}
const { username, email, password } = req.body;
// Check if user already exists