mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 00:04:48 -07:00
Simpler forgot password functionality (#2393)
* Simpler forgot password functionality (Server/Client)
This commit is contained in:
parent
b64eab204c
commit
0cfa6863d5
36 changed files with 1190 additions and 173 deletions
|
|
@ -36,6 +36,9 @@
|
|||
#include "main.h"
|
||||
#include "window_main.h"
|
||||
#include "dlg_connect.h"
|
||||
#include "dlg_forgotpasswordrequest.h"
|
||||
#include "dlg_forgotpasswordreset.h"
|
||||
#include "dlg_forgotpasswordchallenge.h"
|
||||
#include "dlg_register.h"
|
||||
#include "dlg_settings.h"
|
||||
#include "dlg_update.h"
|
||||
|
|
@ -166,9 +169,10 @@ void MainWindow::activateAccepted()
|
|||
|
||||
void MainWindow::actConnect()
|
||||
{
|
||||
DlgConnect dlg(this);
|
||||
if (dlg.exec())
|
||||
client->connectToServer(dlg.getHost(), dlg.getPort(), dlg.getPlayerName(), dlg.getPassword());
|
||||
DlgConnect *dlg = new DlgConnect(this);
|
||||
connect(dlg, SIGNAL(sigStartForgotPasswordRequest()), this, SLOT(actForgotPasswordRequest()));
|
||||
if (dlg->exec())
|
||||
client->connectToServer(dlg->getHost(), dlg->getPort(), dlg->getPlayerName(), dlg->getPassword());
|
||||
}
|
||||
|
||||
void MainWindow::actRegister()
|
||||
|
|
@ -506,6 +510,9 @@ void MainWindow::setClientStatusTitle()
|
|||
case StatusDisconnected: setWindowTitle(appName + " - " + tr("Disconnected")); break;
|
||||
case StatusLoggingIn: setWindowTitle(appName + " - " + tr("Connected, logging in at %1").arg(client->peerName())); break;
|
||||
case StatusLoggedIn: setWindowTitle(client->getUserName() + "@" + client->peerName()); break;
|
||||
case StatusRequestingForgotPassword: setWindowTitle(appName + " - " + tr("Requesting forgot password to %1 as %2...").arg(client->peerName()).arg(client->getUserName())); break;
|
||||
case StatusSubmitForgotPasswordChallenge: setWindowTitle(appName + " - " + tr("Requesting forgot password to %1 as %2...").arg(client->peerName()).arg(client->getUserName())); break;
|
||||
case StatusSubmitForgotPasswordReset: setWindowTitle(appName + " - " + tr("Requesting forgot password to %1 as %2...").arg(client->peerName()).arg(client->getUserName())); break;
|
||||
default: setWindowTitle(appName);
|
||||
}
|
||||
}
|
||||
|
|
@ -666,6 +673,10 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
connect(client, SIGNAL(registerError(Response::ResponseCode, QString, quint32)), this, SLOT(registerError(Response::ResponseCode, QString, quint32)));
|
||||
connect(client, SIGNAL(activateAccepted()), this, SLOT(activateAccepted()));
|
||||
connect(client, SIGNAL(activateError()), this, SLOT(activateError()));
|
||||
connect(client, SIGNAL(sigForgotPasswordSuccess()), this, SLOT(forgotPasswordSuccess()));
|
||||
connect(client, SIGNAL(sigForgotPasswordError()), this, SLOT(forgotPasswordError()));
|
||||
connect(client, SIGNAL(sigPromptForForgotPasswordReset()), this, SLOT(promptForgotPasswordReset()));
|
||||
connect(client, SIGNAL(sigPromptForForgotPasswordChallenge()), this, SLOT(promptForgotPasswordChallenge()));
|
||||
|
||||
clientThread = new QThread(this);
|
||||
client->moveToThread(clientThread);
|
||||
|
|
@ -734,6 +745,13 @@ void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason) {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::promptForgotPasswordChallenge()
|
||||
{
|
||||
DlgForgotPasswordChallenge dlg(this);
|
||||
if (dlg.exec())
|
||||
client->submitForgotPasswordChallengeToServer(dlg.getHost(),dlg.getPort(),dlg.getPlayerName(),dlg.getEmail());
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::createTrayActions() {
|
||||
closeAction = new QAction(tr("&Exit"), this);
|
||||
|
|
@ -1054,3 +1072,34 @@ void MainWindow::actEditTokens()
|
|||
dlg.exec();
|
||||
db->saveCustomTokensToFile();
|
||||
}
|
||||
|
||||
void MainWindow::actForgotPasswordRequest()
|
||||
{
|
||||
DlgForgotPasswordRequest dlg(this);
|
||||
if (dlg.exec())
|
||||
client->requestForgotPasswordToServer(dlg.getHost(), dlg.getPort(), dlg.getPlayerName());
|
||||
}
|
||||
|
||||
void MainWindow::forgotPasswordSuccess()
|
||||
{
|
||||
QMessageBox::information(this, tr("Forgot Password"), tr("Your password has been reset successfully, you now may log in using the new credentials."));
|
||||
settingsCache->servers().setFPHostName("");
|
||||
settingsCache->servers().setFPPort("");
|
||||
settingsCache->servers().setFPPlayerName("");
|
||||
}
|
||||
|
||||
void MainWindow::forgotPasswordError()
|
||||
{
|
||||
QMessageBox::warning(this, tr("Forgot Password"), tr("Failed to reset user account password, please contact the server operator to reset your password."));
|
||||
settingsCache->servers().setFPHostName("");
|
||||
settingsCache->servers().setFPPort("");
|
||||
settingsCache->servers().setFPPlayerName("");
|
||||
}
|
||||
|
||||
void MainWindow::promptForgotPasswordReset()
|
||||
{
|
||||
QMessageBox::information(this, tr("Forgot Password"), tr("Activation request received, please check your email for an activation token."));
|
||||
DlgForgotPasswordReset dlg(this);
|
||||
if (dlg.exec())
|
||||
client->submitForgotPasswordResetToServer(dlg.getHost(), dlg.getPort(), dlg.getPlayerName(), dlg.getToken(), dlg.getPassword());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue