Reverted password loading in PAGE_SETUP, changed the value of passwordlength to save, added clearing of hashes after a 'Wrong password' RetryDialog
authorOndrej Skopek <skopekondrej@gmail.com>
Fri, 14 Dec 2012 18:49:25 +0100
changeset 8297 b236e3afed0d
parent 8296 455da122c0ad
child 8298 f9e6da8f94b1
Reverted password loading in PAGE_SETUP, changed the value of passwordlength to save, added clearing of hashes after a 'Wrong password' RetryDialog
QTfrontend/gameuiconfig.cpp
QTfrontend/hwform.cpp
--- a/QTfrontend/gameuiconfig.cpp	Thu Dec 13 20:34:44 2012 +0100
+++ b/QTfrontend/gameuiconfig.cpp	Fri Dec 14 18:49:25 2012 +0100
@@ -233,13 +233,11 @@
     setValue("audio/volume", Form->ui.pageOptions->volumeBox->value());
 
     setValue("net/nick", netNick());
-    if ((netPasswordLength()==0)) {
-	setValue("net/passwordhash", "");
-        setValue("net/passwordlength", 0);
+    if (netPasswordIsValid() && Form->ui.pageOptions->CBSavePassword->isChecked()) {
+	setPasswordHash(netPasswordHash());
     }
-    else if (netPasswordIsValid() && Form->ui.pageOptions->CBSavePassword->isChecked()) {
-	setValue("net/passwordhash", "");
-	setValue("net/passwordlength", 0);
+    else if(!Form->ui.pageOptions->CBSavePassword->isChecked()) {
+        clearPasswordHash();
     }
 
     setValue("net/savepassword", Form->ui.pageOptions->CBSavePassword->isChecked());
@@ -490,8 +488,8 @@
 void GameUIConfig::setPasswordHash(const QString & passwordhash)
 {
     setValue("net/passwordhash", passwordhash);
-    setValue("net/passwordlength", passwordhash.size());
-    setNetPasswordLength(passwordhash.size());
+    setValue("net/passwordlength", passwordhash.size()/4);
+    setNetPasswordLength(passwordhash.size()/4);  //the hash.size() is divided by 4 let PAGE_SETUP use a reasonable number of stars to display the PW
 }
 
 QString GameUIConfig::passwordHash()
--- a/QTfrontend/hwform.cpp	Thu Dec 13 20:34:44 2012 +0100
+++ b/QTfrontend/hwform.cpp	Fri Dec 14 18:49:25 2012 +0100
@@ -1127,6 +1127,8 @@
     bool retry = RetryDialog(tr("Hedgewars - Wrong password"), tr("You entered a wrong password."));
     GoBack();
 
+    config->clearPasswordHash();
+    config->clearTempHash();
     if (retry) {
        NetConnectOfficialServer();
     }