This is a new mostly bash-based implementation of a minimal and immanent AO server. No database, user accounts are created directly in the OS.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

29 lines
904 B

const express = require('express');
const router = express.Router();
const { execSync } = require('child_process');
router.post('/register', (req, res) => {
const { username, password } = req.body;
if (!username || !password) {
return res.status(400).json({ error: 'Username and password are required' });
}
execSync(`create-user ${username} ${password}`, (error, stdout, stderr) => {
if (error) {
console.log('errer')
if (error.message.includes('already exists')) {
// User already exists error handling
res.status(409).json({ message: 'Username already exists' });
} else {
// Other error handling
console.error(error);
res.status(500).json({ message: 'An error occurred during registration' });
}
} else {
res.status(200).json({ message: 'Registration successful' });
}
});
});
module.exports = router