43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
/**
|
|
* Password Hash Generator for Weight Tracker
|
|
*
|
|
* This script generates a bcrypt hash for a given password that can be used
|
|
* with the Weight Tracker application's authentication system.
|
|
*
|
|
* Usage:
|
|
* node generate-password.js <your-password>
|
|
*/
|
|
|
|
const bcrypt = require('bcryptjs');
|
|
|
|
// Get password from command line arguments
|
|
const password = process.argv[2];
|
|
|
|
if (!password) {
|
|
console.error('Error: Password is required');
|
|
console.log('Usage: node generate-password.js <your-password>');
|
|
process.exit(1);
|
|
}
|
|
|
|
// Generate salt and hash
|
|
const saltRounds = 10;
|
|
bcrypt.genSalt(saltRounds, (err, salt) => {
|
|
if (err) {
|
|
console.error('Error generating salt:', err);
|
|
process.exit(1);
|
|
}
|
|
|
|
bcrypt.hash(password, salt, (err, hash) => {
|
|
if (err) {
|
|
console.error('Error generating hash:', err);
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('\nPassword Hash for Nginx Basic Authentication:');
|
|
console.log(hash);
|
|
console.log('\nUse this hash in your PASSWORD_HASH environment variable in Coolify.');
|
|
console.log('Example:');
|
|
console.log(`PASSWORD_HASH=${hash}`);
|
|
});
|
|
});
|