diff --git a/database/migrations/0009-login_users_plug_holes.ts b/database/migrations/0009-login_users_plug_holes.ts index dc13ab671..9366c2e59 100644 --- a/database/migrations/0009-login_users_plug_holes.ts +++ b/database/migrations/0009-login_users_plug_holes.ts @@ -6,6 +6,15 @@ */ export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + // Generate a random private key where the remaining data is present + await queryFn( + `UPDATE login_users SET privkey = UNHEX(SHA1(RAND())) + WHERE privkey IS NULL + AND pubkey IS NOT NULL + AND password != 0 + AND id IN (SELECT user_id FROM login_user_backups);`, + ) + // Remove incomplete data and set account as not activated yet. await queryFn( `UPDATE login_users SET password = 0, pubkey = NULL, email_checked = 0 WHERE privkey IS NULL;`,