Credential's "Remember" checkbox logic revised

This commit is contained in:
Simon Rozman 2016-07-21 23:52:36 +02:00
parent 6ae8029a47
commit 3e60bebe3a
2 changed files with 14 additions and 13 deletions

View File

@ -397,11 +397,11 @@ public:
m_cfg(cfg), m_cfg(cfg),
m_cred(cred), m_cred(cred),
m_target(pszCredTarget), m_target(pszCredTarget),
m_is_config(is_config),
_Tbase(parent) _Tbase(parent)
{ {
if (m_target.empty() || is_config) { if (m_is_config) {
// No Credential Manager, or user is setting credentials via configuration UI. // In configuration mode, always store credentials (somewhere).
// => Pointless if not stored to Credential Manager
m_remember->SetValue(true); m_remember->SetValue(true);
m_remember->Enable(false); m_remember->Enable(false);
} }
@ -412,17 +412,17 @@ protected:
virtual bool TransferDataToWindow() virtual bool TransferDataToWindow()
{ {
if (!m_target.empty()) { if (!m_target.empty() && m_is_config) {
// Read credentials from Credential Manager // Read credentials from Credential Manager
EAP_ERROR *pEapError; EAP_ERROR *pEapError;
if (m_cred.retrieve(m_target.c_str(), &pEapError)) { if (!m_cred.retrieve(m_target.c_str(), &pEapError)) {
m_remember->SetValue(true); if (pEapError) {
} else if (pEapError) { if (pEapError->dwWinError != ERROR_NOT_FOUND)
if (pEapError->dwWinError != ERROR_NOT_FOUND) wxLogError(winstd::tstring_printf(_("Error reading credentials from Credential Manager: %ls (error %u)"), pEapError->pRootCauseString, pEapError->dwWinError).c_str());
wxLogError(winstd::tstring_printf(_("Error reading credentials from Credential Manager: %ls (error %u)"), pEapError->pRootCauseString, pEapError->dwWinError).c_str()); m_cred.m_module.free_error_memory(pEapError);
m_cred.m_module.free_error_memory(pEapError); } else
} else wxLogError(_("Reading credentials failed."));
wxLogError(_("Reading credentials failed.")); }
} }
return _Tbase::TransferDataToWindow(); return _Tbase::TransferDataToWindow();
@ -457,6 +457,7 @@ protected:
const eap::config_method &m_cfg; ///< Method configuration const eap::config_method &m_cfg; ///< Method configuration
eap::credentials &m_cred; ///< Generic credentials eap::credentials &m_cred; ///< Generic credentials
winstd::tstring m_target; ///< Credential Manager target winstd::tstring m_target; ///< Credential Manager target
bool m_is_config; ///< Is this a configuration dialog?
}; };

View File

@ -101,7 +101,7 @@ bool eap::peer_ttls_ui::invoke_identity_ui(
// Create and launch credentials dialog. // Create and launch credentials dialog.
wxEAPCredentialsDialog dlg(cfg_prov, &parent); wxEAPCredentialsDialog dlg(cfg_prov, &parent);
wxTTLSCredentialsPanel *panel = new wxTTLSCredentialsPanel(cfg_prov, *cfg_method, cred, cfg_prov.m_id.c_str(), &dlg, true); wxTTLSCredentialsPanel *panel = new wxTTLSCredentialsPanel(cfg_prov, *cfg_method, cred, cfg_prov.m_id.c_str(), &dlg);
dlg.AddContents((wxPanel**)&panel, 1); dlg.AddContents((wxPanel**)&panel, 1);
result = dlg.ShowModal(); result = dlg.ShowModal();