User Management Commands
Use these commands in the terminal to manage user accounts:
🔐 Change User Password
First, generate a password hash:
cd /var/www/quote-system
node -e "const bcrypt = require('bcrypt'); bcrypt.hash('NEW_PASSWORD', 10).then(hash => console.log(hash));"
Then update the database with the hash:
psql -h localhost -U quote_app -d quote_system
Password: quoteapp123
UPDATE users SET password_hash = 'PASTE_HASH_HERE' WHERE email = 'user@example.com';
\q
✉️ Change User Email
psql -h localhost -U quote_app -d quote_system
Password: quoteapp123
UPDATE users SET email = 'newemail@example.com' WHERE email = 'oldemail@example.com';
\q
👤 View All Users
psql -h localhost -U quote_app -d quote_system
Password: quoteapp123
SELECT id, email, first_name, last_name, role FROM users;
\q
➕ Add New User
First, generate a password hash (see "Change User Password" above).
Then insert the new user:
psql -h localhost -U quote_app -d quote_system
Password: quoteapp123
INSERT INTO users (email, password_hash, first_name, last_name, role)
VALUES ('newuser@example.com', 'PASTE_HASH_HERE', 'First', 'Last', 'user');
\q
Note: role can be 'admin' or 'user'
🗑️ Deactivate User
psql -h localhost -U quote_app -d quote_system
Password: quoteapp123
UPDATE users SET is_active = false WHERE email = 'user@example.com';
\q
🔓 Reactivate User
psql -h localhost -U quote_app -d quote_system
Password: quoteapp123
UPDATE users SET is_active = true WHERE email = 'user@example.com';
\q