Skip to content

Commit c979ed9

Browse files
committed
Only try to authenticate when possible
1 parent 03ea427 commit c979ed9

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/commands.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,14 @@ export class Commands {
265265
vscode.workspace.getConfiguration(),
266266
);
267267
const needsToken = needToken(vscode.workspace.getConfiguration());
268-
try {
269-
const user = await client.getAuthenticatedUser();
270-
// For non-token auth, we write a blank token since the `vscodessh`
271-
// command currently always requires a token file.
272-
// For token auth, we have valid access so we can just return the user here
273-
return { token: needsToken && token ? token : "", user };
274-
} catch (err) {
275-
if (!needToken(vscode.workspace.getConfiguration())) {
268+
if (!needsToken || token) {
269+
try {
270+
const user = await client.getAuthenticatedUser();
271+
// For non-token auth, we write a blank token since the `vscodessh`
272+
// command currently always requires a token file.
273+
// For token auth, we have valid access so we can just return the user here
274+
return { token: needsToken && token ? token : "", user };
275+
} catch (err) {
276276
const message = getErrorMessage(err, "no response from the server");
277277
if (isAutoLogin) {
278278
this.logger.warn("Failed to log in to Coder server:", message);

0 commit comments

Comments
 (0)