1b4b497fdf
Mirror to GitHub / mirror (push) Successful in 44s
Test and Lint / backend-test (push) Successful in 1m42s
Test and Lint / frontend-test (push) Has been cancelled
Version and Release / version-bump (push) Has been cancelled
Version and Release / trigger-drone (push) Has been cancelled
- Remove all console.log/debug statements from production code - Add NODE_ENV checks for development-only logging - Remove test scripts (test-feedback, test-image-security, test-backup-*, test-restore) - Remove one-time fix scripts (fix-temp-photos, fix-migration-state, mark-migration-applied) - Remove sensitive files (.env.backup, ADMIN_CREDENTIALS.txt) - Update package.json to remove references to deleted scripts - Replace console statements with logger utility in backend - Secure error boundaries to not expose stack traces in production This makes the codebase production-ready with no debug output or test scripts. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
67 lines
1.9 KiB
JavaScript
67 lines
1.9 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Show or reset admin credentials
|
|
*/
|
|
|
|
const bcrypt = require('bcrypt');
|
|
const { db } = require('../src/database/db');
|
|
const { generateReadablePassword } = require('../src/utils/passwordGenerator');
|
|
|
|
async function showAdminCredentials(resetPassword = false) {
|
|
try {
|
|
// Get admin user
|
|
const admin = await db('admin_users')
|
|
.where('username', 'admin')
|
|
.first();
|
|
|
|
if (!admin) {
|
|
console.error('❌ No admin user found in database');
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('\n========================================');
|
|
console.log('PicPeak Admin Credentials');
|
|
console.log('========================================');
|
|
console.log(`Username: ${admin.username}`);
|
|
console.log(`Email: ${admin.email}`);
|
|
|
|
if (resetPassword) {
|
|
// Generate new password
|
|
const newPassword = generateReadablePassword();
|
|
const passwordHash = await bcrypt.hash(newPassword, 12);
|
|
|
|
// Update password
|
|
await db('admin_users')
|
|
.where('id', admin.id)
|
|
.update({
|
|
password_hash: passwordHash,
|
|
updated_at: new Date()
|
|
});
|
|
|
|
// Password logging removed for security - check logs or database if needed
|
|
console.log('Password: [NEWLY RESET - stored in database]');
|
|
console.log('\n⚠️ IMPORTANT: New password has been set in database!');
|
|
} else {
|
|
console.log('Password: [hidden - use --reset flag to generate new password]');
|
|
}
|
|
|
|
console.log('\nLogin URL: http://localhost:3001/admin');
|
|
console.log('========================================\n');
|
|
|
|
} catch (error) {
|
|
console.error('Error:', error.message);
|
|
process.exit(1);
|
|
} finally {
|
|
await db.destroy();
|
|
}
|
|
}
|
|
|
|
// Check for reset flag
|
|
const resetPassword = process.argv.includes('--reset');
|
|
|
|
if (resetPassword) {
|
|
console.log('🔄 Resetting admin password...');
|
|
}
|
|
|
|
showAdminCredentials(resetPassword); |