From c29bf1ae1716b344ef97853bb251e231f1f9f56c Mon Sep 17 00:00:00 2001 From: Zach H Date: Mon, 13 Jul 2015 20:30:05 -0400 Subject: [PATCH] require pass & email confirmation --- cockatrice/src/dlg_register.cpp | 41 ++++++++++++++++++++++++++------- cockatrice/src/dlg_register.h | 4 ++-- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/cockatrice/src/dlg_register.cpp b/cockatrice/src/dlg_register.cpp index 4470cc3e..54442f10 100644 --- a/cockatrice/src/dlg_register.cpp +++ b/cockatrice/src/dlg_register.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "dlg_register.h" @@ -33,10 +34,19 @@ DlgRegister::DlgRegister(QWidget *parent) passwordLabel->setBuddy(passwordEdit); passwordEdit->setEchoMode(QLineEdit::Password); + passwordConfirmationLabel = new QLabel(tr("Password (again):")); + passwordConfirmationEdit = new QLineEdit(); + passwordConfirmationLabel->setBuddy(passwordConfirmationEdit); + passwordConfirmationEdit->setEchoMode(QLineEdit::Password); + emailLabel = new QLabel(tr("Email:")); emailEdit = new QLineEdit(); emailLabel->setBuddy(emailEdit); + emailConfirmationLabel = new QLabel(tr("Email (again):")); + emailConfirmationEdit = new QLineEdit(); + emailConfirmationLabel->setBuddy(emailConfirmationEdit); + genderLabel = new QLabel(tr("Pronouns:")); genderEdit = new QComboBox(); genderLabel->setBuddy(genderEdit); @@ -69,14 +79,18 @@ DlgRegister::DlgRegister(QWidget *parent) grid->addWidget(playernameEdit, 2, 1); grid->addWidget(passwordLabel, 3, 0); grid->addWidget(passwordEdit, 3, 1); - grid->addWidget(emailLabel, 4, 0); - grid->addWidget(emailEdit, 4, 1); - grid->addWidget(genderLabel, 5, 0); - grid->addWidget(genderEdit, 5, 1); - grid->addWidget(countryLabel, 6, 0); - grid->addWidget(countryEdit, 6, 1); - grid->addWidget(realnameLabel, 7, 0); - grid->addWidget(realnameEdit, 7, 1); + grid->addWidget(passwordConfirmationLabel, 4, 0); + grid->addWidget(passwordConfirmationEdit, 4, 1); + grid->addWidget(emailLabel, 5, 0); + grid->addWidget(emailEdit, 5, 1); + grid->addWidget(emailConfirmationLabel, 6, 0); + grid->addWidget(emailConfirmationEdit, 6, 1); + grid->addWidget(genderLabel, 7, 0); + grid->addWidget(genderEdit, 7, 1); + grid->addWidget(countryLabel, 8, 0); + grid->addWidget(countryEdit, 8, 1); + grid->addWidget(realnameLabel, 9, 0); + grid->addWidget(realnameEdit, 9, 1); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(buttonBox, SIGNAL(accepted()), this, SLOT(actOk())); @@ -94,6 +108,17 @@ DlgRegister::DlgRegister(QWidget *parent) void DlgRegister::actOk() { + if (passwordEdit->text() != passwordConfirmationEdit->text()) + { + QMessageBox::critical(this, tr("Registration Warning"), tr("Your passwords do not match, please try again.")); + return; + } + else if (emailConfirmationEdit->text() != emailEdit->text()) + { + QMessageBox::critical(this, tr("Registration Warning"), tr("Your email addresses do not match, please try again.")); + return; + } + QSettings settings; settings.beginGroup("server"); settings.setValue("hostname", hostEdit->text()); diff --git a/cockatrice/src/dlg_register.h b/cockatrice/src/dlg_register.h index 3ee7b105..f0e2ecf2 100644 --- a/cockatrice/src/dlg_register.h +++ b/cockatrice/src/dlg_register.h @@ -25,8 +25,8 @@ private slots: void actOk(); void actCancel(); private: - QLabel *hostLabel, *portLabel, *playernameLabel, *passwordLabel, *emailLabel, *genderLabel, *countryLabel, *realnameLabel; - QLineEdit *hostEdit, *portEdit, *playernameEdit, *passwordEdit, *emailEdit, *realnameEdit; + QLabel *hostLabel, *portLabel, *playernameLabel, *passwordLabel, *passwordConfirmationLabel, *emailLabel, *emailConfirmationLabel, *genderLabel, *countryLabel, *realnameLabel; + QLineEdit *hostEdit, *portEdit, *playernameEdit, *passwordEdit, *passwordConfirmationEdit, *emailEdit, *emailConfirmationEdit, *realnameEdit; QComboBox *genderEdit, *countryEdit; };