From 94fcebc13acee47cfb40eeaeeba8f606099529e6 Mon Sep 17 00:00:00 2001 From: "Albert.Zhou" Date: Wed, 20 Nov 2013 18:41:38 +0800 Subject: [PATCH] bug fix: offline login without remote verify --- src/wizLoginDialog.cpp | 44 ++++++++++++++++++++++++++++-------------- src/wizLoginDialog.h | 2 +- src/wizdef.h | 2 +- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/wizLoginDialog.cpp b/src/wizLoginDialog.cpp index 8acb7df69..b9907b1e1 100644 --- a/src/wizLoginDialog.cpp +++ b/src/wizLoginDialog.cpp @@ -186,27 +186,43 @@ void CWizLoginDialog::accept() void CWizLoginDialog::doAccountVerify() { - CWizKMAccountsServer server(WizKMGetAccountsServerURL(true)); - if (server.Login(userId(), password(), "normal") && - updateProfile(userId(), server.GetUserInfo())) { - QDialog::accept(); + CWizUserSettings userSettings(userId()); + + // FIXME: should verify password if network is available to avoid attack? + if (password() != userSettings.password()) { + CWizKMAccountsServer server(WizKMGetAccountsServerURL(true)); + if (server.Login(userId(), password(), "normal") && + updateProfile(userSettings, userId(), server.GetUserInfo())) { + + CWizSettings settings(::WizGetDataStorePath() + "wiznote.ini"); + settings.SetString("Users", "DefaultUser", userId()); + + QDialog::accept(); + } else { + QMessageBox::critical(this, tr("Verify account failed"), server.GetLastErrorMessage()); + } } else { - QMessageBox::critical(this, tr("Verify account failed"), server.GetLastErrorMessage()); + CWizSettings settings(::WizGetDataStorePath() + "wiznote.ini"); + settings.SetString("Users", "DefaultUser", userId()); + + if (m_checkAutoLogin->checkState() == Qt::Checked) { + userSettings.setAutoLogin(true); + } else { + userSettings.setAutoLogin(false); + } + + if (m_checkSavePassword->checkState() != Qt::Checked) { + userSettings.setPassword(); + } + + QDialog::accept(); } enableControls(true); } -bool CWizLoginDialog::updateProfile(const QString& strUserId, const WIZKMUSERINFO& info) +bool CWizLoginDialog::updateProfile(CWizUserSettings& userSettings, const QString& strUserId, const WIZKMUSERINFO& info) { - CWizSettings settings(::WizGetDataStorePath() + "wiznote.ini"); - - // set current login user as default user. - settings.SetString("Users", "DefaultUser", strUserId); - - // login flags - CWizUserSettings userSettings(strUserId ); - if(m_checkAutoLogin->checkState() == Qt::Checked) { userSettings.setAutoLogin(true); } else { diff --git a/src/wizLoginDialog.h b/src/wizLoginDialog.h index 2411d1680..d59b07dfa 100644 --- a/src/wizLoginDialog.h +++ b/src/wizLoginDialog.h @@ -34,7 +34,7 @@ class CWizLoginDialog : public QDialog void enableControls(bool bEnable); void doAccountVerify(); - bool updateProfile(const QString& strUserId, const WIZKMUSERINFO& info); + bool updateProfile(CWizUserSettings& settings, const QString& strUserId, const WIZKMUSERINFO& info); void setUsers(const QString& strDefault); void setUser(const QString& userId); diff --git a/src/wizdef.h b/src/wizdef.h index 425c55c48..80250872f 100644 --- a/src/wizdef.h +++ b/src/wizdef.h @@ -3,7 +3,7 @@ #include -#define WIZ_CLIENT_VERSION "2.0.63" +#define WIZ_CLIENT_VERSION "2.0.64" #define WIZNOTE_FTS_VERSION "5" #define WIZNOTE_THUMB_VERSION "3"