Skip to content

Commit f47f554

Browse files
committed
init
Signed-off-by: jace-roell <[email protected]>
1 parent 0189e1f commit f47f554

File tree

5 files changed

+40
-5
lines changed

5 files changed

+40
-5
lines changed

packages/zowe-explorer/src/configuration/Profiles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,8 +890,8 @@ export class Profiles extends ProfilesCache {
890890
comment: ["Service profile name"],
891891
})
892892
);
893-
AuthHandler.unlockProfile(serviceProfile, true);
894893
ZoweVsCodeExtension.onProfileUpdatedEmitter.fire(serviceProfile);
894+
AuthHandler.unlockProfile(serviceProfile, true);
895895
}
896896
return loginOk;
897897
} catch (err) {

packages/zowe-explorer/src/trees/dataset/DatasetFSProvider.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,14 @@ export class DatasetFSProvider extends BaseProvider implements vscode.FileSystem
8585
isFetching = queryParams.has("fetch") && queryParams.get("fetch") === "true";
8686
}
8787

88-
const entry = isFetching ? await this.remoteLookupForResource(uri) : this.lookup(uri, false);
8988
const uriInfo = FsAbstractUtils.getInfoForUri(uri, Profiles.getInstance());
89+
90+
if (AuthHandler.sessTypeFromProfile(uriInfo.profile) === imperative.SessConstants.AUTH_TYPE_TOKEN && !uriInfo.profile.profile.tokenValue) {
91+
throw vscode.FileSystemError.Unavailable("Profile is using token type but missing a token");
92+
}
93+
94+
const entry = isFetching ? await this.remoteLookupForResource(uri) : this.lookup(uri, false);
95+
9096
// Do not perform remote lookup for profile or directory URIs; the code below is for change detection on PS or PDS members only
9197
if (uriInfo.isRoot || FsAbstractUtils.isDirectoryEntry(entry)) {
9298
return entry;
@@ -255,6 +261,10 @@ export class DatasetFSProvider extends BaseProvider implements vscode.FileSystem
255261
let pdsMember: boolean;
256262
let uriPath: string[];
257263

264+
if (AuthHandler.sessTypeFromProfile(uriInfo.profile) === imperative.SessConstants.AUTH_TYPE_TOKEN && !uriInfo.profile.profile.tokenValue) {
265+
throw vscode.FileSystemError.Unavailable("Profile is using token type but missing a token");
266+
}
267+
258268
await AuthUtils.retryRequest(uriInfo.profile, async () => {
259269
try {
260270
entry = this.lookup(uri, false) as PdsEntry | DsEntry;

packages/zowe-explorer/src/trees/shared/SharedInit.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
imperative,
2525
AuthHandler,
2626
FsAbstractUtils,
27+
UriFsInfo,
2728
} from "@zowe/zowe-explorer-api";
2829
import { SharedActions } from "./SharedActions";
2930
import { SharedHistoryView } from "./SharedHistoryView";
@@ -445,15 +446,28 @@ export class SharedInit {
445446
const profInfo = Profiles.getInstance();
446447
const profileNames = new Set<string>();
447448

449+
let uriMap = new Map<string, UriFsInfo>();
448450
if (profileType) {
449451
profInfo.getProfiles(profileType).forEach((prof) => profileNames.add(prof.name));
450452
newWorkspaces = newWorkspaces.filter((f) => {
451-
const uriInfo = FsAbstractUtils.getInfoForUri(f.uri);
453+
const uriInfo = FsAbstractUtils.getInfoForUri(f.uri, profInfo);
454+
uriMap[f.uri.path] = uriInfo;
452455
return profileNames.has(uriInfo.profileName);
453456
});
454457
}
455458

456459
for (const folder of newWorkspaces) {
460+
const uriInfo = uriMap[folder.uri.path];
461+
462+
const session = ZoweExplorerApiRegister.getInstance().getCommonApi(uriInfo.profile).getSession(uriInfo.profile);
463+
if (
464+
(session.ISession.type === imperative.SessConstants.AUTH_TYPE_TOKEN ||
465+
session.ISession.type === imperative.SessConstants.AUTH_TYPE_NONE) &&
466+
!uriInfo.profile.profile.tokenValue
467+
) {
468+
throw vscode.FileSystemError.Unavailable("Profile is using token type but missing a token");
469+
}
470+
457471
try {
458472
await (folder.uri.scheme === ZoweScheme.DS ? DatasetFSProvider.instance : UssFSProvider.instance).remoteLookupForResource(folder.uri);
459473
} catch (err) {

packages/zowe-explorer/src/trees/uss/UssFSProvider.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,12 @@ export class UssFSProvider extends BaseProvider implements vscode.FileSystemProv
7777
isFetching = queryParams.has("fetch") && queryParams.get("fetch") === "true";
7878
}
7979

80-
const entry = isFetching ? await this.remoteLookupForResource(uri) : this.lookup(uri, false);
8180
const uriInfo = FsAbstractUtils.getInfoForUri(uri, Profiles.getInstance());
81+
if (AuthHandler.sessTypeFromProfile(uriInfo.profile) === imperative.SessConstants.AUTH_TYPE_TOKEN && !uriInfo.profile.profile.tokenValue) {
82+
throw vscode.FileSystemError.Unavailable("Profile is using token type but missing a token");
83+
}
84+
const entry = isFetching ? await this.remoteLookupForResource(uri) : this.lookup(uri, false);
85+
8286
// Do not perform remote lookup for profile or directory URIs; the code below is for change detection on USS files only
8387
if (uriInfo.isRoot || FsAbstractUtils.isDirectoryEntry(entry)) {
8488
return entry;
@@ -208,6 +212,10 @@ export class UssFSProvider extends BaseProvider implements vscode.FileSystemProv
208212
private async fetchEntries(uri: vscode.Uri, uriInfo: UriFsInfo): Promise<UssDirectory | UssFile> {
209213
const entryExists = this.exists(uri);
210214

215+
if (AuthHandler.sessTypeFromProfile(uriInfo.profile) === imperative.SessConstants.AUTH_TYPE_TOKEN && !uriInfo.profile.profile.tokenValue) {
216+
throw vscode.FileSystemError.Unavailable("Profile is using token type but missing a token");
217+
}
218+
211219
// Wait for any ongoing authentication process to complete
212220
await AuthUtils.reauthenticateIfCancelled(uriInfo.profile);
213221
await AuthHandler.waitForUnlock(uriInfo.profile);

packages/zowe-explorer/src/utils/AuthUtils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { ZoweLogger } from "../tools/ZoweLogger";
2727
import { SharedTreeProviders } from "../trees/shared/SharedTreeProviders";
2828
import { SettingsConfig } from "../configuration/SettingsConfig";
2929
import { SharedContext } from "../trees/shared/SharedContext";
30+
import { ImperativeError } from "@zowe/imperative";
3031

3132
interface ErrorContext {
3233
apiType?: ZoweExplorerApiType;
@@ -47,7 +48,9 @@ export class AuthUtils {
4748
if (AuthHandler.isProfileLocked(profile) && AuthHandler.wasAuthCancelled(profile)) {
4849
// The original error doesn't matter here, we just need to trigger the flow.
4950
await this.handleProfileAuthOnError(
50-
new Error("User cancelled previous authentication, but a new action requires authentication. Prompting user to re-authenticate."),
51+
new ImperativeError({
52+
msg: "User cancelled previous authentication, but a new action requires authentication. Prompting user to re-authenticate. (All configured authentication methods failed)",
53+
}),
5154
profile
5255
);
5356
}

0 commit comments

Comments
 (0)