Skip to content

Commit

Permalink
bug fix: offline login without remote verify
Browse files Browse the repository at this point in the history
  • Loading branch information
Albert.Zhou committed Nov 20, 2013
1 parent a06dff3 commit 94fcebc
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
44 changes: 30 additions & 14 deletions src/wizLoginDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/wizLoginDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/wizdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <QtGlobal>

#define WIZ_CLIENT_VERSION "2.0.63"
#define WIZ_CLIENT_VERSION "2.0.64"
#define WIZNOTE_FTS_VERSION "5"
#define WIZNOTE_THUMB_VERSION "3"

Expand Down

0 comments on commit 94fcebc

Please sign in to comment.