Monorepo for wisp.place. A static site hosting service built on top of the AT Protocol. wisp.place
96
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 9ee137eeaa5e227342cf68d08feddb986975cd71 46 lines 1.3 kB view raw
1// Change admin password 2import { adminAuth } from './src/lib/admin-auth' 3import { db } from './src/lib/db' 4import { randomBytes, createHash } from 'crypto' 5 6// Get username and new password from command line 7const username = process.argv[2] 8const newPassword = process.argv[3] 9 10if (!username || !newPassword) { 11 console.error('Usage: bun run change-admin-password.ts <username> <new-password>') 12 process.exit(1) 13} 14 15if (newPassword.length < 8) { 16 console.error('Password must be at least 8 characters') 17 process.exit(1) 18} 19 20// Hash password 21function hashPassword(password: string, salt: string): string { 22 return createHash('sha256').update(password + salt).digest('hex') 23} 24 25function generateSalt(): string { 26 return randomBytes(32).toString('hex') 27} 28 29// Initialize 30await adminAuth.init() 31 32// Check if user exists 33const result = await db`SELECT username FROM admin_users WHERE username = ${username}` 34if (result.length === 0) { 35 console.error(`Admin user '${username}' not found`) 36 process.exit(1) 37} 38 39// Update password 40const salt = generateSalt() 41const passwordHash = hashPassword(newPassword, salt) 42 43await db`UPDATE admin_users SET password_hash = ${passwordHash}, salt = ${salt} WHERE username = ${username}` 44 45console.log(`✓ Password updated for admin user '${username}'`) 46process.exit(0)