470 if (lst[0] == "ASKPASSWORD") { |
470 if (lst[0] == "ASKPASSWORD") { |
471 bool ok = false; |
471 bool ok = false; |
472 int passLength = config->value("net/passwordlength", 0).toInt(); |
472 int passLength = config->value("net/passwordlength", 0).toInt(); |
473 QString hash = config->value("net/passwordhash", "").toString(); |
473 QString hash = config->value("net/passwordhash", "").toString(); |
474 QString password = QInputDialog::getText(0, tr("Password"), tr("Your nickname %1 is\nregistered on Hedgewars.org\nPlease provide your password below\nor pick another nickname in game config:").arg(mynick), QLineEdit::Password, passLength==0?NULL:QString(passLength,'\0'), &ok); |
474 QString password = QInputDialog::getText(0, tr("Password"), tr("Your nickname %1 is\nregistered on Hedgewars.org\nPlease provide your password below\nor pick another nickname in game config:").arg(mynick), QLineEdit::Password, passLength==0?NULL:QString(passLength,'\0'), &ok); |
475 |
475 |
476 if (!ok) { |
476 if (!ok) { |
477 Disconnect(); |
477 Disconnect(); |
478 emit Disconnected(); |
478 emit Disconnected(); |
479 return; |
479 return; |
480 } |
480 } |
481 |
481 |
482 if (!passLength || password!=QString(passLength, '\0')) { |
482 if (!passLength || password!=QString(passLength, '\0')) { |
483 hash = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5).toHex(); |
483 hash = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5).toHex(); |
484 config->setValue("net/passwordhash", hash); |
484 config->setValue("net/passwordhash", hash); |
485 config->setValue("net/passwordlength", password.size()); |
485 config->setValue("net/passwordlength", password.size()); |
486 } |
486 } |