From c478da1d132250b7d0ebfa372b4a1faea3211e3e Mon Sep 17 00:00:00 2001 From: lelemm Date: Mon, 11 Nov 2024 13:59:30 -0300 Subject: [PATCH] Update src/account-db.js Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/account-db.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/account-db.js b/src/account-db.js index 90e68c7ff..3c095f04b 100644 --- a/src/account-db.js +++ b/src/account-db.js @@ -156,9 +156,17 @@ export async function disableOpenID( return { error }; } - getAccountDb().mutate('DELETE FROM sessions'); - getAccountDb().mutate('DELETE FROM users WHERE user_name <> ?', ['']); - getAccountDb().mutate('DELETE FROM auth WHERE method = ?', ['openid']); + const accountDb = getAccountDb(); + accountDb.mutate('BEGIN TRANSACTION'); + try { + accountDb.mutate('DELETE FROM sessions'); + accountDb.mutate('DELETE FROM users WHERE user_name <> ?', ['']); + accountDb.mutate('DELETE FROM auth WHERE method = ?', ['openid']); + accountDb.mutate('COMMIT'); + } catch (error) { + accountDb.mutate('ROLLBACK'); + throw error; + } } export function getSession(token) {