Skip to content

Commit

Permalink
Merge pull request #378 from zowe/Fix-for-Issue#375
Browse files Browse the repository at this point in the history
Add validation for undefined username and password + more cosmetic fix
  • Loading branch information
Colin-Stone authored Dec 11, 2019
2 parents 369e057 + 6f9a8a8 commit 86c16bc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
16 changes: 9 additions & 7 deletions i18n/sample/src/Profiles.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
"loadNamedProfile.warn.noDefaultProfile": "Unable to locate a default profile. CLI may not be installed. ",
"createNewConnection.option.prompt.url.placeholder": "https://url:port",
"createNewConnection.option.prompt.url": "Enter a z/OSMF URL in the format 'https://url:port'.",
"createNewConnection.enterzosmfURL": "No valid value for z/OSMF URL. Operation Cancelled",
"createNewConnection.option.prompt.userName.placeholder": "Optional: User Name",
"createNewConnection.option.prompt.userName": "Enter the user name for the connection",
"createNewConnection.zosmfURL": "No valid value for z/OSMF URL. Operation Cancelled",
"createNewConnection.option.prompt.username.placeholder": "Optional: User Name",
"createNewConnection.option.prompt.username": "Enter the user name for the connection. Leave blank to not store.",
"createNewConnection.undefined.username": "Operation Cancelled",
"createNewConnection.option.prompt.password.placeholder": "Optional: Password",
"createNewConnection.option.prompt.password": "Enter a password for the connection",
"createNewConnection.option.prompt.password": "Enter the password for the connection. Leave blank to not store.",
"createNewConnection.undefined.password": "Operation Cancelled",
"createNewConnection.option.prompt.ru.placeholder": "Reject Unauthorized Connections",
"createNewConnection.rejectUnauthorize": "Operation Cancelled",
"createNewConnection.duplicateProfileName": "Profile name already exists. Please create a profile using a different name",
"promptcredentials.option.prompt.userName.placeholder": "User Name",
"promptcredentials.option.prompt.userName": "Enter the user name for the connection",
"promptcredentials.option.prompt.username.placeholder": "User Name",
"promptcredentials.option.prompt.username": "Enter the user name for the connection",
"promptcredentials.invalidusername": "Please enter your z/OS username. Operation Cancelled",
"promptcredentials.option.prompt.passWord.placeholder": "Password",
"promptcredentials.option.prompt.password.placeholder": "Password",
"promptcredentials.option.prompt.password": "Enter a password for the connection",
"promptcredentials.invalidpassword": "Please enter your z/OS password. Operation Cancelled"
}
24 changes: 18 additions & 6 deletions src/Profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,28 +155,40 @@ export class Profiles { // Processing stops if there are no profiles detected
});

if (!zosmfURL) {
vscode.window.showInformationMessage(localize("createNewConnection.enterzosmfURL",
vscode.window.showInformationMessage(localize("createNewConnection.zosmfURL",
"No valid value for z/OSMF URL. Operation Cancelled"));
return undefined;
}

const zosmfUrlParsed = this.validateAndParseUrl(zosmfURL);

options = {
placeHolder: localize("createNewConnection.option.prompt.userName.placeholder", "Optional: User Name"),
prompt: localize("createNewConnection.option.prompt.userName", "Enter the user name for the connection"),
placeHolder: localize("createNewConnection.option.prompt.username.placeholder", "Optional: User Name"),
prompt: localize("createNewConnection.option.prompt.username", "Enter the user name for the connection. Leave blank to not store."),
value: userName
};
userName = await vscode.window.showInputBox(options);

if (userName === undefined) {
vscode.window.showInformationMessage(localize("createNewConnection.undefined.username",
"Operation Cancelled"));
return;
}

options = {
placeHolder: localize("createNewConnection.option.prompt.password.placeholder", "Optional: Password"),
prompt: localize("createNewConnection.option.prompt.password", "Enter a password for the connection"),
prompt: localize("createNewConnection.option.prompt.password", "Enter the password for the connection. Leave blank to not store."),
password: true,
value: passWord
};
passWord = await vscode.window.showInputBox(options);

if (passWord === undefined) {
vscode.window.showInformationMessage(localize("createNewConnection.undefined.passWord",
"Operation Cancelled"));
return;
}

const quickPickOptions: vscode.QuickPickOptions = {
placeHolder: localize("createNewConnection.option.prompt.ru.placeholder", "Reject Unauthorized Connections"),
ignoreFocusOut: true,
Expand Down Expand Up @@ -240,8 +252,8 @@ export class Profiles { // Processing stops if there are no profiles detected
if (!loadSession.user) {

options = {
placeHolder: localize("promptcredentials.option.prompt.userName.placeholder", "User Name"),
prompt: localize("promptcredentials.option.prompt.userName", "Enter the user name for the connection"),
placeHolder: localize("promptcredentials.option.prompt.username.placeholder", "User Name"),
prompt: localize("promptcredentials.option.prompt.username", "Enter the user name for the connection"),
value: userName
};
userName = await vscode.window.showInputBox(options);
Expand Down

0 comments on commit 86c16bc

Please sign in to comment.