Skip to content

Commit c7df45f

Browse files
committed
Only try to authenticate when possible
1 parent 20bc214 commit c7df45f

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
@@ -252,14 +252,14 @@ export class Commands {
252252
vscode.workspace.getConfiguration(),
253253
);
254254
const needsToken = needToken(vscode.workspace.getConfiguration());
255-
try {
256-
const user = await client.getAuthenticatedUser();
257-
// For non-token auth, we write a blank token since the `vscodessh`
258-
// command currently always requires a token file.
259-
// For token auth, we have valid access so we can just return the user here
260-
return { token: needsToken && token ? token : "", user };
261-
} catch (err) {
262-
if (!needToken(vscode.workspace.getConfiguration())) {
255+
if (!needsToken || token) {
256+
try {
257+
const user = await client.getAuthenticatedUser();
258+
// For non-token auth, we write a blank token since the `vscodessh`
259+
// command currently always requires a token file.
260+
// For token auth, we have valid access so we can just return the user here
261+
return { token: needsToken && token ? token : "", user };
262+
} catch (err) {
263263
const message = getErrorMessage(err, "no response from the server");
264264
if (isAutoLogin) {
265265
this.logger.warn("Failed to log in to Coder server:", message);

0 commit comments

Comments
 (0)