Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/authentication/gitpodServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ async function getUserInfo(token: string, serviceUrl: string, logger: ILogServic
};
}

const ACTION_COPY = 'Copy to clipboard';
const ACTION_CANCEL = 'Cancel';

export default class GitpodServer extends Disposable {

public static AUTH_COMPLETE_PATH = '/complete-gitpod-auth';
Expand Down Expand Up @@ -76,8 +79,16 @@ export default class GitpodServer extends Disposable {
location: vscode.ProgressLocation.Window,
title: `Signing in to ${this._serviceUrl}...`,
}, async () => {
await vscode.env.openExternal(uri as any);
// this._logger.trace(">> URL ", uri);
const success = await vscode.env.openExternal(uri as any);
if (!success) {
// Handle the case where the extension can't open a browser window
const action = await vscode.window.showWarningMessage('There was a problem opening the login URL in your browser. Please copy it into your browser manually.', ACTION_COPY, ACTION_CANCEL);
if (action === ACTION_COPY) {
await vscode.env.clipboard.writeText(uri);
} else if (action === ACTION_CANCEL) {
throw new Error('Signin cancelled by user');
}
}

// Register a single listener for the URI callback, in case the user starts the login process multiple times
// before completing it.
Expand Down