require pass & email confirmation

This commit is contained in:
Zach H 2015-07-13 20:30:05 -04:00
parent 8a0fdd2089
commit c29bf1ae17
2 changed files with 35 additions and 10 deletions

View file

@ -4,6 +4,7 @@
#include <QGridLayout>
#include <QHBoxLayout>
#include <QDialogButtonBox>
#include <QMessageBox>
#include <QDebug>
#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());

View file

@ -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;
};