fixed settings sync has duplicate logins (#142340)

* added check and swaped logic

* improved label for usename

* fixed eslint issues

* updated text
This commit is contained in:
Yash Goel
2022-02-09 01:44:52 +05:30
committed by GitHub
parent 69a7a37ced
commit 5ea92ff535

View File

@@ -204,6 +204,12 @@ export class AzureActiveDirectoryService {
}
public createSession(scopes: string[]): Promise<vscode.AuthenticationSession> {
if (!scopes.includes('openid')) {
scopes.push('openid');
}
if (!scopes.includes('email')) {
scopes.push('email');
}
const scopeData: IScopeData = {
scopes,
scopeStr: scopes.join(' '),
@@ -390,14 +396,14 @@ export class AzureActiveDirectoryService {
let claims = undefined;
try {
claims = JSON.parse(Buffer.from(json.access_token.split('.')[1], 'base64').toString());
} catch (e) {
if (json.id_token) {
Logger.info('Attempting to parse id_token instead since access_token was not parsable');
claims = JSON.parse(Buffer.from(json.id_token.split('.')[1], 'base64').toString());
} else {
throw e;
claims = JSON.parse(Buffer.from(json.access_token.split('.')[1], 'base64').toString());
}
} catch (e) {
throw e;
}
return {
@@ -409,7 +415,7 @@ export class AzureActiveDirectoryService {
scope: scopeData.scopeStr,
sessionId: existingId || `${claims.tid}/${(claims.oid || (claims.altsecid || '' + claims.ipd || ''))}/${uuid()}`,
account: {
label: claims.email || claims.unique_name || claims.preferred_username || 'user@example.com',
label: `${claims.name} - ${claims.email}` || claims.email || claims.unique_name || claims.preferred_username || 'user@example.com',
id: `${claims.tid}/${(claims.oid || (claims.altsecid || '' + claims.ipd || ''))}`
}
};