mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 01:23:24 -08:00
Unticking 'Save password' only disabled auto-connect: the dialog still handed the stored verifier to the connection, so a password typed at the same time was ignored, and a server that still has the legacy hash refused the login before it could upgrade the account. Clear the verifier in effect on untick, restore it on re-tick unless a password has been typed, and drop the stale 'Password saved' hint. The downgrade abort can now point at unticking the box and logging in with the password, without the extra reconnect round-trip. Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
108 lines
3.3 KiB
C++
108 lines
3.3 KiB
C++
/**
|
|
* @file dlg_connect.h
|
|
* @ingroup ConnectionDialogs
|
|
*/
|
|
//! \todo Document this file.
|
|
|
|
#ifndef DLG_CONNECT_H
|
|
#define DLG_CONNECT_H
|
|
|
|
#include <QCheckBox>
|
|
#include <QDialog>
|
|
#include <QLineEdit>
|
|
#include <QMap>
|
|
#include <QString>
|
|
#include <libcockatrice/utility/macros.h>
|
|
#include <qtmetamacros.h>
|
|
#include <utility>
|
|
|
|
class QCheckBox;
|
|
class QComboBox;
|
|
class QGridLayout;
|
|
class QGroupBox;
|
|
class QHBoxLayout;
|
|
class QLabel;
|
|
class QPushButton;
|
|
class QRadioButton;
|
|
class QVBoxLayout;
|
|
class HandlePublicServers;
|
|
class QWidget;
|
|
class UserConnection_Information;
|
|
|
|
class DlgConnect : public QDialog
|
|
{
|
|
Q_OBJECT
|
|
signals:
|
|
void sigStartForgotPasswordRequest();
|
|
void sigPublicServersDownloaded();
|
|
|
|
public:
|
|
explicit DlgConnect(QWidget *parent = nullptr);
|
|
~DlgConnect() override;
|
|
[[nodiscard]] QString getHost() const;
|
|
[[nodiscard]] int getPort() const
|
|
{
|
|
return portEdit->text().toInt();
|
|
}
|
|
[[nodiscard]] QString getPlayerName() const
|
|
{
|
|
return playernameEdit->text();
|
|
}
|
|
[[nodiscard]] QString getPassword() const
|
|
{
|
|
return passwordEdit->text();
|
|
}
|
|
//! \brief Stored "$scrypt$..." verifier for challenge-response servers (never the plaintext password).
|
|
[[nodiscard]] QString getStoredVerifier() const
|
|
{
|
|
return storedVerifier;
|
|
}
|
|
[[nodiscard]] QString getSaveName() const
|
|
{
|
|
// Trim so the profile lookup key always matches the name DlgConnect::actOk
|
|
// stored (it saves under saveEdit->text().trimmed()); otherwise a trailing
|
|
// space here misses the index and silently drops the saved verifier.
|
|
return saveEdit->text().trimmed();
|
|
}
|
|
[[nodiscard]] bool getSavePassword() const
|
|
{
|
|
return savePasswordCheckBox->isChecked();
|
|
}
|
|
|
|
public slots:
|
|
void downloadThePublicServers();
|
|
|
|
private slots:
|
|
void actOk();
|
|
|
|
void passwordSaved(QT_STATE_CHANGED_T state);
|
|
void previousHostSelected(bool state);
|
|
void newHostSelected(bool state);
|
|
void actForgotPassword();
|
|
void actRemoveSavedServer();
|
|
void updateDisplayInfo(const QString &saveName);
|
|
void preRebuildComboBoxList();
|
|
void rebuildComboBoxList(int failure = -1);
|
|
|
|
private:
|
|
QGridLayout *connectionLayout, *loginLayout, *serverInfoLayout, *grid;
|
|
QHBoxLayout *newHolderLayout, *forgotPasswordLayout;
|
|
QGroupBox *loginGroupBox, *serverInfoGroupBox, *restrictionsGroupBox;
|
|
QVBoxLayout *mainLayout;
|
|
QLabel *hostLabel, *portLabel, *playernameLabel, *passwordLabel, *saveLabel, *serverIssuesLabel,
|
|
*serverContactLabel, *serverContactLink, *forgotPasswordLabel;
|
|
QLineEdit *hostEdit, *portEdit, *playernameEdit, *passwordEdit, *saveEdit;
|
|
QCheckBox *savePasswordCheckBox, *autoConnectCheckBox;
|
|
QComboBox *previousHosts;
|
|
QRadioButton *newHostButton, *previousHostButton;
|
|
QPushButton *btnConnect, *btnForgotPassword, *btnRefreshServers, *btnDeleteServer;
|
|
QMap<QString, std::pair<QString, UserConnection_Information>> savedHostList;
|
|
HandlePublicServers *hps;
|
|
//! \brief Saved "$scrypt$..." verifier as loaded for the selected profile, kept so that
|
|
//! re-ticking "Save password" after unticking restores it.
|
|
QString savedVerifier;
|
|
//! \brief Verifier in effect for this connection: empty while "Save password" is unticked.
|
|
QString storedVerifier;
|
|
const QString placeHolderText = tr("Downloading...");
|
|
};
|
|
#endif
|