Bug 1892304 - Add the FxA uid and email to the backup manifest if signed in when creating a backup. r=backup-reviewers,kpatenio

Differential Revision: https://phabricator.services.mozilla.com/D208191
This commit is contained in:
Mike Conley
2024-04-25 13:07:09 +00:00
parent 1c59a3b390
commit 0f19114d70
3 changed files with 108 additions and 6 deletions

View File

@@ -25,6 +25,7 @@ ChromeUtils.defineLazyGetter(lazy, "fxAccounts", () => {
ChromeUtils.defineESModuleGetters(lazy, {
JsonSchemaValidator:
"resource://gre/modules/components-utils/JsonSchemaValidator.sys.mjs",
UIState: "resource://services-sync/UIState.sys.mjs",
});
/**
@@ -400,6 +401,16 @@ export class BackupService {
profileName = profileSvc.currentProfile.name;
}
// Default these to undefined rather than null so that they're not included
// the meta object if we're not signed in.
let accountID = undefined;
let accountEmail = undefined;
let fxaState = lazy.UIState.get();
if (fxaState.status == lazy.UIState.STATUS_SIGNED_IN) {
accountID = fxaState.uid;
accountEmail = fxaState.email;
}
return {
version: BackupService.MANIFEST_SCHEMA_VERSION,
meta: {
@@ -411,6 +422,8 @@ export class BackupService {
machineName: lazy.fxAccounts.device.getLocalName(),
osName: Services.sysinfo.getProperty("name"),
osVersion: Services.sysinfo.getProperty("version"),
accountID,
accountEmail,
},
resources: {},
};