From 9d1587f00861ba9e98b92a3198d31481349de27e Mon Sep 17 00:00:00 2001 From: Amir Omidi Date: Mon, 27 Jul 2020 15:36:20 -0700 Subject: [PATCH] Special case personal accounts (#11538) * Special case personal accounts * Add comments --- .../azurecore/src/account-provider/auths/azureAuth.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/extensions/azurecore/src/account-provider/auths/azureAuth.ts b/extensions/azurecore/src/account-provider/auths/azureAuth.ts index 9c681e6d3f..688889e4e8 100644 --- a/extensions/azurecore/src/account-provider/auths/azureAuth.ts +++ b/extensions/azurecore/src/account-provider/auths/azureAuth.ts @@ -261,8 +261,16 @@ export abstract class AzureAuth implements vscode.Disposable { } const tokenClaims: TokenClaims = this.getTokenClaims(accessTokenString); + let userKey: string; - const userKey = tokenClaims.home_oid ?? tokenClaims.oid ?? tokenClaims.unique_name ?? tokenClaims.sub; + // Personal accounts don't have an oid when logging into the `common` tenant, but when logging into their home tenant they end up having an oid. + // This makes the key for the same account be different. + // We need to special case personal accounts. + if (tokenClaims.idp === 'live.com') { // Personal account + userKey = tokenClaims.unique_name ?? tokenClaims.email ?? tokenClaims.sub; + } else { + userKey = tokenClaims.home_oid ?? tokenClaims.oid ?? tokenClaims.unique_name ?? tokenClaims.email ?? tokenClaims.sub; + } if (!userKey) { const msg = localize('azure.noUniqueIdentifier', "The user had no unique identifier within AAD");