Skip to content

Commit f88f1d7

Browse files
Avoids reading state on redirect url (which breaks github.dev redirects)
1 parent 171242c commit f88f1d7

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

src/plus/integrations/integrationService.ts

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ export interface ConnectionStateChangeEvent {
5555
reason: 'connected' | 'disconnected';
5656
}
5757

58-
interface CloudIntegrationConnectionAuth {
59-
code: string | undefined;
60-
state: string | undefined;
61-
}
62-
6358
export class IntegrationService implements Disposable {
6459
private readonly _onDidChangeConnectionState = new EventEmitter<ConnectionStateChangeEvent>();
6560
get onDidChangeConnectionState(): Event<ConnectionStateChangeEvent> {
@@ -234,20 +229,17 @@ export class IntegrationService implements Disposable {
234229
await env.openExternal(this.container.getGkDevUri('connect', query));
235230
}
236231

237-
const deferredCallback = promisifyDeferred<Uri, CloudIntegrationConnectionAuth>(
232+
const deferredCallback = promisifyDeferred<Uri, string | undefined>(
238233
this.container.uri.onDidReceiveCloudIntegrationAuthenticationUri,
239234
(uri: Uri, resolve) => {
240235
const queryParams: URLSearchParams = new URLSearchParams(uri.query);
241-
resolve({
242-
code: queryParams.get('code') ?? undefined,
243-
state: queryParams.get('state') ?? undefined,
244-
});
236+
resolve(queryParams.get('code') ?? undefined);
245237
},
246238
);
247239

248-
let authData: CloudIntegrationConnectionAuth = { code: undefined, state: undefined };
240+
let code: string | undefined;
249241
try {
250-
authData = await window.withProgress(
242+
code = await window.withProgress(
251243
{
252244
location: ProgressLocation.Notification,
253245
title: 'Connecting integrations...',
@@ -256,13 +248,11 @@ export class IntegrationService implements Disposable {
256248
(_, token) => {
257249
return Promise.race([
258250
deferredCallback.promise,
259-
new Promise<CloudIntegrationConnectionAuth>((_, reject) =>
251+
new Promise<string | undefined>((_, reject) =>
260252
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
261253
token.onCancellationRequested(() => reject('Cancelled')),
262254
),
263-
new Promise<CloudIntegrationConnectionAuth>((_, reject) =>
264-
setTimeout(reject, 5 * 60 * 1000, 'Cancelled'),
265-
),
255+
new Promise<string | undefined>((_, reject) => setTimeout(reject, 5 * 60 * 1000, 'Cancelled')),
266256
]);
267257
},
268258
);
@@ -273,10 +263,8 @@ export class IntegrationService implements Disposable {
273263
}
274264

275265
if (account == null) {
276-
if (authData.code == null) return false;
277-
await this.container.subscription.loginWithCode(
278-
{ code: authData.code, state: authData.state } /*, source: source*/,
279-
);
266+
if (code == null) return false;
267+
await this.container.subscription.loginWithCode({ code: code }, source);
280268
account = (await this.container.subscription.getSubscription()).account;
281269
if (account == null) return false;
282270
}

0 commit comments

Comments
 (0)