summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/configuration.cpp1
-rw-r--r--src/gui/windows/logindialog.cpp23
-rw-r--r--src/gui/windows/logindialog.h1
-rw-r--r--src/net/ea/loginhandler.cpp19
-rw-r--r--src/net/logindata.h2
-rw-r--r--src/progs/manaplus/client.cpp30
6 files changed, 48 insertions, 28 deletions
diff --git a/src/configuration.cpp b/src/configuration.cpp
index dd3f36923..1e6ba66da 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -220,6 +220,7 @@ const std::string unusedKeys[] =
"OutfitAwayIndex",
"playerHomes",
"remember",
+ "remember_password",
"screenshotDirectory",
""
};
diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp
index 168b1b76a..787f741fc 100644
--- a/src/gui/windows/logindialog.cpp
+++ b/src/gui/windows/logindialog.cpp
@@ -74,14 +74,12 @@ LoginDialog::LoginDialog(LoginData &data,
mUserField(new TextField(this, mLoginData->username,
LoseFocusOnTab_true, nullptr, std::string(), false)),
mPassField(new PasswordField(this, mLoginData->password)),
-#ifdef SAVE_PASSWORD
// TRANSLATORS: login dialog label
- mKeepCheck(new CheckBox(this, _("Remember user and password"),
-#else
+ mKeepCheck(new CheckBox(this, _("username"),
+ mLoginData->remember, nullptr, std::string())),
// TRANSLATORS: login dialog label
- mKeepCheck(new CheckBox(this, _("Remember username"),
-#endif
- mLoginData->remember, nullptr, std::string())),
+ mKeepPwCheck(new CheckBox(this, _("password"),
+ mLoginData->remember_password, nullptr, std::string())),
// TRANSLATORS: login dialog label
mUpdateTypeLabel(new Label(this, _("Update:"))),
mUpdateTypeModel(new UpdateTypeModel),
@@ -124,6 +122,8 @@ LoginDialog::LoginDialog(LoginData &data,
Label *const userLabel = new Label(this, _("Name:"));
// TRANSLATORS: login dialog label
Label *const passLabel = new Label(this, _("Password:"));
+ // TRANSLATORS: login dialog label
+ Label *const rememberLabel = new Label(this, _("Remember:"));
if (mServer->updateHosts.size() > 1)
{
mUpdateListModel = new UpdateListModel(mServer);
@@ -177,10 +177,12 @@ LoginDialog::LoginDialog(LoginData &data,
}
place(0, n, mCustomUpdateHost, 9, 1);
place(0, n + 1, mUpdateHostText, 9, 1);
- place(0, n + 2, mKeepCheck, 9, 1);
- place(0, n + 3, mRegisterButton, 1, 1).setHAlign(LayoutCell::LEFT);
- place(2, n + 3, mServerButton, 1, 1);
- place(3, n + 3, mLoginButton, 1, 1);
+ place(0, n + 2, rememberLabel, 1, 1);
+ place(2, n + 2, mKeepCheck, 1, 1);
+ place(2, n + 3, mKeepPwCheck, 1, 1);
+ place(0, n + 4, mRegisterButton, 1, 1).setHAlign(LayoutCell::LEFT);
+ place(2, n + 4, mServerButton, 1, 1);
+ place(3, n + 4, mLoginButton, 1, 1);
addKeyListener(this);
}
@@ -324,6 +326,7 @@ void LoginDialog::prepareUpdate()
mLoginData->username = mUserField->getText();
mLoginData->password = mPassField->getText();
mLoginData->remember = mKeepCheck->isSelected();
+ mLoginData->remember_password = mKeepPwCheck->isSelected();
UpdateTypeT updateType = static_cast<UpdateTypeT>(
mUpdateTypeDropDown->getSelected());
diff --git a/src/gui/windows/logindialog.h b/src/gui/windows/logindialog.h
index f57eb882b..b859308c0 100644
--- a/src/gui/windows/logindialog.h
+++ b/src/gui/windows/logindialog.h
@@ -95,6 +95,7 @@ class LoginDialog final : public Window,
TextField *mUserField A_NONNULLPOINTER;
TextField *mPassField A_NONNULLPOINTER;
CheckBox *mKeepCheck A_NONNULLPOINTER;
+ CheckBox *mKeepPwCheck A_NONNULLPOINTER;
Label *mUpdateTypeLabel A_NONNULLPOINTER;
UpdateTypeModel *mUpdateTypeModel A_NONNULLPOINTER;
DropDown *mUpdateTypeDropDown A_NONNULLPOINTER;
diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp
index 2fc177476..fbae0813f 100644
--- a/src/net/ea/loginhandler.cpp
+++ b/src/net/ea/loginhandler.cpp
@@ -153,21 +153,20 @@ void LoginHandler::loginOrRegister(LoginData *const data) const
const bool remember = data->remember;
if (remember)
- {
serverConfig.setValue("username", data->username);
-#ifdef SAVE_PASSWORD
- serverConfig.setValue("password", data->password);
-#endif
- }
else
- {
serverConfig.setValue("username", "");
-#ifdef SAVE_PASSWORD
- serverConfig.setValue("password", "");
-#endif
- }
+
serverConfig.setValue("remember", remember);
+ const bool remember_password = data->remember_password;
+ if (remember_password)
+ serverConfig.setValue("password", data->password);
+ else
+ serverConfig.setValue("password", "");
+
+ serverConfig.setValue("remember_password", remember_password);
+
// Clear the password, avoids auto login when returning to login
data->password.clear();
}
diff --git a/src/net/logindata.h b/src/net/logindata.h
index 68306dced..61a3d1c7a 100644
--- a/src/net/logindata.h
+++ b/src/net/logindata.h
@@ -48,6 +48,7 @@ class LoginData final
gender(Gender::UNSPECIFIED),
packetVersion(0),
remember(false),
+ remember_password(false),
registerLogin(false),
characterSlots(9)
{
@@ -71,6 +72,7 @@ class LoginData final
int packetVersion;
bool remember; // Whether to store the username.
+ bool remember_password; // Whether to store the password.
bool registerLogin; // Whether an account is being registered.
uint16_t characterSlots; // The number of character slots
diff --git a/src/progs/manaplus/client.cpp b/src/progs/manaplus/client.cpp
index d8ba7e1c2..6b05b0809 100644
--- a/src/progs/manaplus/client.cpp
+++ b/src/progs/manaplus/client.cpp
@@ -497,6 +497,7 @@ void Client::gameInit()
loginData.password = settings.options.password;
LoginDialog::savedPassword = settings.options.password;
loginData.remember = (serverConfig.getValue("remember", 1) != 0);
+ loginData.remember_password = (serverConfig.getValue("remember_password", 1) != 0);
loginData.registerLogin = false;
if (mCurrentServer.hostname.empty())
@@ -517,6 +518,9 @@ void Client::gameInit()
if (loginData.username.empty() && loginData.remember)
loginData.username = serverConfig.getValue("username", "");
+
+ if (loginData.password.empty() && loginData.remember_password)
+ loginData.password = serverConfig.getValue("password", "");
if (mState != State::ERROR)
mState = State::CHOOSE_SERVER;
@@ -853,16 +857,28 @@ void Client::stateConnectServer1()
{
loginData.username = settings.options.username;
}
-#ifdef SAVE_PASSWORD
- LoginDialog::savedPassword = loginData.remember ?
- serverConfig.getValue("password", "") : "";
- loginData.password = LoginDialog::savedPassword;
- settings.options.password = LoginDialog::savedPassword;
-#endif
+
+ if (settings.options.password.empty())
+ {
+ if (loginData.remember_password)
+ {
+ LoginDialog::savedPassword = serverConfig.getValue("password", "");
+ loginData.password = LoginDialog::savedPassword;
+ settings.options.password = LoginDialog::savedPassword;
+ }
+ else
+ loginData.password.clear();
+ }
+ else
+ {
+ loginData.password = settings.options.password;
+ }
+
settings.login = loginData.username;
WindowManager::updateTitle();
loginData.remember = (serverConfig.getValue("remember", 1) != 0);
+ loginData.remember_password = (serverConfig.getValue("remember_password", 1) != 0);
Net::connectToServer(mCurrentServer);
#ifdef USE_MUMBLE
@@ -1638,13 +1654,11 @@ int Client::gameExec()
case State::ERROR:
BLOCK_START("Client::gameExec State::ERROR")
config.write();
-#ifdef SAVE_PASSWORD
if (errorMessage == "Wrong password.")
{
serverConfig.setValue("password", "");
serverConfig.write();
}
-#endif
if (mOldState == State::GAME)
serverConfig.write();
logger->log1("State: ERROR");