mirror of
https://github.com/bitbaum/evig.git
synced 2026-12-04 11:58:07 +01:00
- Add lazy validation for admin password config (prevents build failures) - Create modular sensitive areas config in src/config/sensitive-areas.ts - Add visual indicator (shield icon) for sensitive sections in admin sidebar - Add "Admin" link in UserMenu for staff members - Add "Website" button in admin header for easy site switching - Fix LogOut icon → User icon for "Mein Bereich" in admin sidebar - Add npm script to generate bcrypt hashes: npm run generate:admin-hash Admin password configuration: - Production requires ADMIN_PASSWORD_HASH (bcrypt) - Development allows ADMIN_PASSWORD (plain text, with warning) - Validation now runs lazily at first use, not during build Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Generate bcrypt hash for admin password
|
|
*
|
|
* Usage:
|
|
* node scripts/generate-admin-hash.js "your-password"
|
|
* npm run generate:admin-hash -- "your-password"
|
|
*
|
|
* Then add the hash to your .env file as:
|
|
* ADMIN_PASSWORD_HASH=$2b$12$...
|
|
*/
|
|
|
|
const bcrypt = require('bcryptjs')
|
|
|
|
const SALT_ROUNDS = 12 // Same as in src/lib/auth/password.ts
|
|
|
|
async function main() {
|
|
const password = process.argv[2]
|
|
|
|
if (!password) {
|
|
console.error('\n❌ Error: Please provide a password as an argument')
|
|
console.log('\nUsage:')
|
|
console.log(' node scripts/generate-admin-hash.js "your-password"')
|
|
console.log(' npm run generate:admin-hash -- "your-password"\n')
|
|
process.exit(1)
|
|
}
|
|
|
|
if (password.length < 8) {
|
|
console.error('\n❌ Error: Password must be at least 8 characters\n')
|
|
process.exit(1)
|
|
}
|
|
|
|
try {
|
|
const hash = await bcrypt.hash(password, SALT_ROUNDS)
|
|
|
|
console.log('\n✅ Bcrypt hash generated successfully!\n')
|
|
console.log('Add this to your .env file:\n')
|
|
console.log(`ADMIN_PASSWORD_HASH=${hash}`)
|
|
console.log('\n⚠️ IMPORTANT: Never commit passwords or hashes to git!\n')
|
|
} catch (error) {
|
|
console.error('\n❌ Error generating hash:', error.message)
|
|
process.exit(1)
|
|
}
|
|
}
|
|
|
|
main()
|