From c841644c9cbe9e7c0a43d1eee6cfdc13d29e5f58 Mon Sep 17 00:00:00 2001 From: "Johannes J. Schmidt" Date: Tue, 2 May 2023 09:22:07 +0000 Subject: [PATCH] Bug 1824112 - switch to `addLoginAsync` r=credential-management-reviewers,sgalich,sync-reviewers,markh Differential Revision: https://phabricator.services.mozilla.com/D175666 --- services/fxaccounts/FxAccountsStorage.sys.mjs | 2 +- services/sync/modules/engines/passwords.sys.mjs | 2 +- .../tps/extensions/tps/resource/modules/passwords.sys.mjs | 1 + toolkit/components/passwordmgr/LoginManagerParent.sys.mjs | 4 +++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/services/fxaccounts/FxAccountsStorage.sys.mjs b/services/fxaccounts/FxAccountsStorage.sys.mjs index a3222275f1b2..6bd74ccc47ac 100644 --- a/services/fxaccounts/FxAccountsStorage.sys.mjs +++ b/services/fxaccounts/FxAccountsStorage.sys.mjs @@ -562,7 +562,7 @@ LoginManagerStorage.prototype = { if (existingLogins.length) { Services.logins.modifyLogin(existingLogins[0], login); } else { - Services.logins.addLogin(login); + await Services.logins.addLoginAsync(login); } log.trace("finished write of user data to the login manager"); } catch (ex) { diff --git a/services/sync/modules/engines/passwords.sys.mjs b/services/sync/modules/engines/passwords.sys.mjs index 7f12d105d12c..e121257d7442 100644 --- a/services/sync/modules/engines/passwords.sys.mjs +++ b/services/sync/modules/engines/passwords.sys.mjs @@ -346,7 +346,7 @@ PasswordStore.prototype = { "formSubmitURL: " + JSON.stringify(login.formActionOrigin) ); - Services.logins.addLogin(login); + await Services.logins.addLoginAsync(login); }, async remove(record) { diff --git a/services/sync/tps/extensions/tps/resource/modules/passwords.sys.mjs b/services/sync/tps/extensions/tps/resource/modules/passwords.sys.mjs index e05a38b6268b..c3835127b7b9 100644 --- a/services/sync/tps/extensions/tps/resource/modules/passwords.sys.mjs +++ b/services/sync/tps/extensions/tps/resource/modules/passwords.sys.mjs @@ -99,6 +99,7 @@ Password.prototype = { this.props.usernameField, this.props.passwordField ); + // TODO: use `addLoginAsync` instead, see https://bugzilla.mozilla.org/show_bug.cgi?id=1829396 Services.logins.addLogin(login); login.QueryInterface(Ci.nsILoginMetaInfo); return login.guid; diff --git a/toolkit/components/passwordmgr/LoginManagerParent.sys.mjs b/toolkit/components/passwordmgr/LoginManagerParent.sys.mjs index e07bc1e9242d..7603f2422827 100644 --- a/toolkit/components/passwordmgr/LoginManagerParent.sys.mjs +++ b/toolkit/components/passwordmgr/LoginManagerParent.sys.mjs @@ -1414,7 +1414,9 @@ export class LoginManagerParent extends JSWindowActorParent { existingLogin.password = formLogin.password; } else if (!autoSavedLogin) { lazy.log("Auto-saving new login with empty username."); - existingLogin = Services.logins.addLogin(formLoginWithoutUsername); + existingLogin = await Services.logins.addLoginAsync( + formLoginWithoutUsername + ); // Remember the GUID where we saved the generated password so we can update // the login if the user later edits the generated password. generatedPW.storageGUID = existingLogin.guid;