45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
/**
|
|
* Password Hash Generator for Weight Tracker
|
|
*
|
|
* This utility script generates a bcrypt hash for your password
|
|
* that can be used in the PASSWORD_HASH environment variable.
|
|
*
|
|
* Usage: node generate-password-hash.js <your-password>
|
|
*/
|
|
|
|
const bcrypt = require('bcryptjs');
|
|
|
|
async function generateHash() {
|
|
// Get password from command line argument
|
|
const password = process.argv[2];
|
|
|
|
if (!password) {
|
|
console.error('Error: No password provided');
|
|
console.log('Usage: node generate-password-hash.js <your-password>');
|
|
process.exit(1);
|
|
}
|
|
|
|
try {
|
|
// Generate hash with bcrypt (cost factor 10)
|
|
const hash = await bcrypt.hash(password, 10);
|
|
|
|
console.log('\nPassword Hash Generated Successfully\n');
|
|
console.log('Copy this hash to your PASSWORD_HASH environment variable in Coolify:');
|
|
console.log('----------------------------------------------------------------');
|
|
console.log(hash);
|
|
console.log('----------------------------------------------------------------\n');
|
|
|
|
console.log('For docker-compose.yml, use:');
|
|
console.log(`PASSWORD_HASH=${hash}\n`);
|
|
|
|
console.log('For .env file, use:');
|
|
console.log(`PASSWORD_HASH=${hash}\n`);
|
|
|
|
} catch (error) {
|
|
console.error('Error generating hash:', error);
|
|
}
|
|
}
|
|
|
|
// Run the function
|
|
generateHash();
|