Browse Source

In generic password dialogs require non-empty inputs

In private key passphrase and dynamic-challenge/pkcs11 PIN
dialogs:

- Disable the OK button by default
- Require non-empty user input before the OK button is enabled

Signed-off-by: Selva Nair <selva.nair@gmail.com>
pull/420/head
Selva Nair 4 years ago
parent
commit
21e09d4603
  1. 24
      openvpn.c

24
openvpn.c

@ -664,6 +664,9 @@ GenericPassDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
else
SetForegroundWindow(hwndDlg);
/* disable OK button by default - not disabled in resources */
EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
break;
case WM_COMMAND:
@ -672,6 +675,15 @@ GenericPassDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
char *fmt;
switch (LOWORD(wParam))
{
case ID_EDT_RESPONSE:
if (HIWORD(wParam) == EN_UPDATE)
{
/* enable OK if response is non-empty */
BOOL enableOK = GetWindowTextLength((HWND) lParam);
EnableWindow(GetDlgItem(hwndDlg, IDOK), enableOK);
}
break;
case IDOK:
if (GetDlgItemTextW(hwndDlg, ID_EDT_RESPONSE, password, _countof(password))
&& !validate_input(password, L"\n"))
@ -782,6 +794,9 @@ PrivKeyPassDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
ForceForegroundWindow(hwndDlg);
else
SetForegroundWindow(hwndDlg);
/* disable OK button by default - not disabled in resources */
EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
break;
case WM_COMMAND:
@ -799,6 +814,15 @@ PrivKeyPassDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
}
break;
case ID_EDT_PASSPHRASE:
if (HIWORD(wParam) == EN_UPDATE)
{
/* enable OK if response is non-empty */
BOOL enableOK = GetWindowTextLength((HWND) lParam);
EnableWindow(GetDlgItem(hwndDlg, IDOK), enableOK);
}
break;
case IDOK:
if (GetDlgItemTextW(hwndDlg, ID_EDT_PASSPHRASE, passphrase, _countof(passphrase)))
{

Loading…
Cancel
Save