Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
password prompt for mail targets
Browse files Browse the repository at this point in the history
  • Loading branch information
mkloubert committed Jun 4, 2017
1 parent 4ba698c commit 8379e15
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 9.16.0 (June 4th, 2017; password prompts)

* password box is shown now if no password is defined in [FTP target](https://github.com/mkloubert/vs-deploy/wiki/target_ftp)
* password box is shown now if no password is defined in [FTP](https://github.com/mkloubert/vs-deploy/wiki/target_ftp) and [mail](https://github.com/mkloubert/vs-deploy/wiki/target_mail) targets

## 9.15.1 (June 4th, 2017; bugfixes and password prompt for SFTP)

Expand Down
59 changes: 47 additions & 12 deletions src/plugins/mail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ class MailPlugin extends deploy_objects.ZipFileDeployPluginBase {

let auth: any;
let user = deploy_helpers.toStringSafe(target.user);
if (user) {
//TODO: password prompt
if ('' !== user) {
let password = deploy_helpers.toStringSafe(target.password);
if ('' === password) {
password = undefined;
}

auth = {
user: user,
Expand Down Expand Up @@ -156,22 +158,55 @@ https://github.com/mkloubert/vs-deploy`,
}
};

vscode.window.showInputBox({
prompt: i18.t('plugins.mail.addressSelector.prompt'),
ignoreFocusOut: true,
placeHolder: i18.t('plugins.mail.addressSelector.placeholder'),
value: to,
}).then((value) => {
to = deploy_helpers.toStringSafe(value).trim();
if (to) {
deploy();
let inputRecipients = () => {
vscode.window.showInputBox({
prompt: i18.t('plugins.mail.addressSelector.prompt'),
ignoreFocusOut: true,
placeHolder: i18.t('plugins.mail.addressSelector.placeholder'),
value: to,
}).then((value) => {
to = deploy_helpers.toStringSafe(value).trim();
if (to) {
deploy();
}
else {
completed();
}
}, (err) => {
completed(err);
});
};

let askForPasswordIfNeeded = () => {
let showPasswordPrompt = false;
if (!deploy_helpers.isEmptyString(auth.user) && deploy_helpers.isNullOrUndefined(auth.password)) {
// user defined, but no password
showPasswordPrompt = deploy_helpers.toBooleanSafe(target.promptForPassword, true);
}

if (showPasswordPrompt) {
vscode.window.showInputBox({
placeHolder: i18.t('prompts.inputPassword'),
password: true,
}).then((passwordFromUser) => {
if ('undefined' === typeof passwordFromUser) {
completed(null); // cancelled
}
else {
completed();
auth.password = passwordFromUser;

inputRecipients();
}
}, (err) => {
completed(err);
});
}
else {
inputRecipients();
}
};

askForPasswordIfNeeded();
}
catch (e) {
completed(e);
Expand Down

0 comments on commit 8379e15

Please sign in to comment.