/** * 本地开发:将所有 auth.users 密码重置为 123456,并打印账号列表 * 用法: npm --prefix server run seed:dev-passwords */ import { pool } from '../src/db'; import { DEV_KNOWN_ACCOUNTS, printDevAccountList, resetDevPasswords, } from '../src/seed-dev-passwords'; async function main() { const result = await resetDevPasswords(pool); printDevAccountList(result.accounts, result.password); console.log(`已更新 ${result.updated} 个账号`); const known = new Set(DEV_KNOWN_ACCOUNTS.map((item) => item.email)); const extra = result.accounts.filter((row) => !known.has(String(row.email))); if (extra.length) { console.log('(另有从生产同步的其他账号,密码也已重置为 123456)'); } await pool.end(); } main().catch(async (error) => { console.error(error); await pool.end().catch(() => undefined); process.exit(1); });