generate random private key for those accounts with an intact passphrase

This commit is contained in:
Ulf Gebhardt 2022-01-22 05:42:01 +01:00
parent 138f09b4e0
commit 54afb80cc2
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9

View File

@ -6,6 +6,15 @@
*/
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// 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;`,