Skip to content

Commit

Permalink
Fix userId read on all auth flows (#974)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyaginidhi committed Jun 13, 2024
1 parent 539f8cb commit e0b63d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/common/copilot/PowerPagesCopilot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,9 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider {
if (session) {
intelligenceApiToken = session.accessToken;
userName = getUserName(session.account.label);
userID = session?.account.id.split("/").pop() ??
session?.account.id;
userID = session?.account.id.split(/[./]/).shift() ??
session?.account.id ??
"";
} else {
intelligenceApiToken = "";
userName = "";
Expand Down
8 changes: 4 additions & 4 deletions src/common/services/AuthenticationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export async function intelligenceAPIAuthentication(telemetry: ITelemetry, sessi
}
accessToken = session?.accessToken ?? '';
user = session.account.label;
userId = session?.account.id.split("/").pop() ??
userId = session?.account.id.split(/[./]/).shift() ??
session?.account.id ??
"";
if (!accessToken) {
Expand Down Expand Up @@ -112,7 +112,7 @@ export async function dataverseAuthentication(
}

accessToken = session?.accessToken ?? "";
userId = session?.account.id.split("/").pop() ??
userId = session?.account.id.split(/[./]/).shift() ??
session?.account.id ??
"";
if (!accessToken) {
Expand Down Expand Up @@ -220,7 +220,7 @@ export async function graphClientAuthentication(
sendTelemetryEvent(telemetry, {
eventName: VSCODE_EXTENSION_GRAPH_CLIENT_AUTHENTICATION_COMPLETED,
userId:
session?.account.id.split("/").pop() ??
session?.account.id.split(/[./]/).shift() ??
session?.account.id ??
"",
});
Expand Down Expand Up @@ -269,7 +269,7 @@ export async function bapServiceAuthentication(
sendTelemetryEvent(telemetry, {
eventName: VSCODE_EXTENSION_BAP_SERVICE_AUTHENTICATION_COMPLETED,
userId:
session?.account.id.split("/").pop() ??
session?.account.id.split(/[./]/).shift() ??
session?.account.id ??
"",
});
Expand Down

0 comments on commit e0b63d6

Please sign in to comment.