Skip to content

Commit 70d638d

Browse files
committed
simp
1 parent 82b0800 commit 70d638d

3 files changed

Lines changed: 4 additions & 10 deletions

File tree

src/commands/connectFolderToServerNamespace.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
serverManagerApi,
88
resolveUsernameAndPassword,
99
} from "../extension";
10-
import { handleError, isUnauthenticated, notIsfs, displayableUri } from "../utils";
10+
import { handleError, notIsfs, displayableUri } from "../utils";
1111

1212
interface ConnSettings {
1313
server: string;
@@ -80,7 +80,7 @@ export async function connectFolderToServerNamespace(): Promise<void> {
8080
.serverInfo(false)
8181
.then((data) => data.result.content.namespaces)
8282
.catch(async (error) => {
83-
if (error?.statusCode == 401 && isUnauthenticated(api.config.authorization.username)) {
83+
if (error?.statusCode == 401 && !api.config.authorization.resolved()) {
8484
// Attempt to resolve username and password and try again
8585
const newSpec = await resolveUsernameAndPassword(api.config.serverName, connSpec);
8686
if (newSpec) {

src/extension.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ import {
8585
portFromDockerCompose,
8686
notNull,
8787
currentFile,
88-
isUnauthenticated,
8988
notIsfs,
9089
handleError,
9190
cspApps,
@@ -472,7 +471,7 @@ export async function checkConnection(
472471
let success = false;
473472
message = "Not Authorized.";
474473
errorMessage = `Authorization error: Check your credentials in Settings, and that you have sufficient privileges on the /api/atelier web application on ${connInfo}`;
475-
if (isUnauthenticated(api.config.authorization.username)) {
474+
if (!api.config.authorization.resolved()) {
476475
vscode.window.showErrorMessage(
477476
`Unauthenticated access rejected by '${api.serverId}'.${
478477
!api.config.serverName ? " Connection has been disabled." : ""

src/utils/index.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -871,11 +871,6 @@ export function methodOffsetToLine(
871871
return line;
872872
}
873873

874-
/** Return `true` if this username signals unauthenticated access */
875-
export function isUnauthenticated(username: string): boolean {
876-
return username == undefined || username == "" || username.toLowerCase() == "unknownuser";
877-
}
878-
879874
/** Returns `true` if `uri.scheme` is neither `isfs` nor `isfs-readonly` */
880875
export function notIsfs(uri: vscode.Uri): boolean {
881876
return !filesystemSchemas.includes(uri.scheme);
@@ -928,7 +923,7 @@ export async function getWsServerConnection(minVersion?: string): Promise<vscode
928923
if (minVersion && lt(config.serverVersion, minVersion)) continue;
929924
const conn = {
930925
label: api.connInfo,
931-
description: isUnauthenticated(config.authorization.username) ? "Unauthenticated" : config.authorization.username,
926+
description: !config.authorization.resolved() ? "Unauthenticated" : config.authorization.username,
932927
detail: `http${config.https ? "s" : ""}://${config.host}:${config.port}${config.pathPrefix}`,
933928
uri: wsFolder.uri,
934929
ns: api.ns,

0 commit comments

Comments
 (0)