Skip to content

Commit

Permalink
Merge pull request #3098 from zowe/prompt/user-pw
Browse files Browse the repository at this point in the history
Prompt to update credentials when outdated credentials stored securely in SSH profile
  • Loading branch information
JillieBeanSim authored Sep 13, 2024
2 parents 5ac43bf + 57d15c1 commit 8146202
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
### Bug fixes

- Fixed JSON errors being ignored when `zowe.config.json` files change on disk and are reloaded. [#3066](https://github.com/zowe/zowe-explorer-vscode/issues/3066) [#3074](https://github.com/zowe/zowe-explorer-vscode/issues/3074)
- Fix issue with outdated SSH credentials stored securely in the SSH profile causing errors. [#2901](https://github.com/zowe/zowe-explorer-vscode/issues/2901)

## `3.0.0-next.202409091409`

Expand Down
6 changes: 4 additions & 2 deletions packages/zowe-explorer/src/commands/UnixCommandHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export class UnixCommandHandler extends ZoweCommandProvider {
comment: ["Profile type"],
})
);
this.serviceProf = undefined;
return;
}
try {
Expand Down Expand Up @@ -245,7 +246,7 @@ export class UnixCommandHandler extends ZoweCommandProvider {
return;
}
const baseProfile = Constants.PROFILES_CACHE.getDefaultProfile("base");
if (baseProfile.profile.user && baseProfile.profile.password) {
if (baseProfile?.profile?.user && baseProfile?.profile?.password) {
this.sshProfile.profile.user = baseProfile.profile.user;
this.sshProfile.profile.password = baseProfile.profile.password;
}
Expand Down Expand Up @@ -353,6 +354,7 @@ export class UnixCommandHandler extends ZoweCommandProvider {

private async issueCommand(profile: imperative.IProfileLoaded, command: string, cwd: string): Promise<void> {
ZoweLogger.trace("UnixCommandHandler.issueCommand called.");
const profName = this.sshProfile !== undefined ? this.sshProfile.name : profile.name;
try {
if (command) {
const user: string = profile.profile.user;
Expand All @@ -377,7 +379,7 @@ export class UnixCommandHandler extends ZoweCommandProvider {
this.serviceProf = undefined;
}
} catch (error) {
await AuthUtils.errorHandling(error, profile.name);
await AuthUtils.errorHandling(error, profName);
}
}
}
5 changes: 4 additions & 1 deletion packages/zowe-explorer/src/utils/AuthUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ export class AuthUtils {
return;
}
}
} else if (httpErrorCode === imperative.RestConstants.HTTP_STATUS_401) {
} else if (
httpErrorCode === imperative.RestConstants.HTTP_STATUS_401 ||
imperativeError.message.includes("All configured authentication methods failed")
) {
const errMsg = vscode.l10n.t({
message:
"Invalid Credentials for profile '{0}'. Please ensure the username and password are valid or this may lead to a lock-out.",
Expand Down

0 comments on commit 8146202

Please sign in to comment.