Compare commits

..

No commits in common. '04e79c627998e46664ba39f14604560b4bb2a362' and '6148484b4f6c5a52727b94fbd73128ad24656383' have entirely different histories.

  1. 2
      routes/register.js
  2. 26
      scripts/create-user

2
routes/register.js

@ -9,7 +9,7 @@ router.post('/register', (req, res) => {
return res.status(400).json({ error: 'Username and password are required' });
}
execSync(`./scripts/create-user ${username} ${password}`, (error, stdout, stderr) => {
execSync(`create-user ${username} ${password}`, (error, stdout, stderr) => {
if (error) {
console.log('errer')
if (error.message.includes('already exists')) {

26
scripts/create-user

@ -1,26 +0,0 @@
#!/bin/sh
# User information
USERNAME="$1"
PASSWORD="$2"
USER_DIRECTORY="./users/$USERNAME"
# Check if the username and password are provided
if [ -z "$USERNAME" ] || [ -z "$PASSWORD" ]; then
echo "Username and password are required."
exit 1
fi
# Create the user (-m creates their home directory)
sudo useradd -m "$USERNAME"
# Check if the user was created successfully
if [ $? -ne 0 ]; then
echo "Failed to create user."
exit 1
fi
# Set the password
echo "$USERNAME:$PASSWORD" | sudo chpasswd
echo "User $USERNAME created successfully."
Loading…
Cancel
Save