Files
pwa/backend/scripts/reset-user-password.ts
T
ar.badieiandCursor 8016b8f45e Polish Novya UI with brand colors, first-load skeletons, and session transition overlay.
Keep chat pinned to the latest message while AI thinks or streams, and align buttons/inputs with the logo teal/blue focus treatment.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-09 01:31:24 +03:30

51 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Dev helper: reset password for a password-auth user.
* Usage: npx tsx scripts/reset-user-password.ts <email> <newPassword>
*/
import { prisma } from '../src/lib/prisma.ts';
import { hashPassword } from '../src/modules/auth/password.ts';
const email = process.argv[2]?.trim().toLowerCase();
const nextPassword = process.argv[3];
if (!email || !nextPassword) {
console.error('Usage: npx tsx scripts/reset-user-password.ts <email> <newPassword>');
process.exit(1);
}
if (nextPassword.length < 8 || nextPassword.length > 128) {
console.error('Password must be 8–128 characters');
process.exit(1);
}
const identity = await prisma.authIdentity.findFirst({
where: {
provider: 'password',
OR: [{ email }, { providerSubject: email }],
},
});
if (!identity) {
console.error(`No password account found for ${email}`);
process.exit(1);
}
const passwordHash = await hashPassword(nextPassword);
await prisma.authIdentity.update({
where: { id: identity.id },
data: { passwordHash },
});
console.log(
JSON.stringify(
{
email: identity.email ?? identity.providerSubject,
passwordUpdated: true,
},
null,
2,
),
);
await prisma.$disconnect();