mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-21 23:00:24 -08:00
Add first draft of protocol extension for registration
Stub for registration command handling in server First draft of handling registration requests WIP (will be rebased) clean up bad imports (rebase this later) Finish checkUserIsBanned method Add username validity check Check servatrice registration settings WIP Finish(?) server side of registration Needs testing Fix switch case compile failure I have no idea why I have to do this WIP for registration testing python script Stub register script initial attempt Rearrange register script First try at sending reg register.py sends commands correctly now Add more debug to register.py Pack bytes the right way - servatrice can parse py script sends now register.py should be working now Parse xml hack correctly Log registration enabled settings on server start Insert gender correctly on register Show tcpserver error message on failed gameserver listen Fail startup if db configured and can't be opened. TIL qt5 comes without mysql by default in homebrew...
This commit is contained in:
@@ -175,6 +175,45 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
|
||||
return authState;
|
||||
}
|
||||
|
||||
RegistrationResult Server::registerUserAccount(const QString &ipAddress, const Command_Register &cmd, QString &banReason, int &banSecondsRemaining)
|
||||
{
|
||||
// TODO
|
||||
|
||||
if (!registrationEnabled)
|
||||
return RegistrationDisabled;
|
||||
|
||||
QString emailAddress = QString::fromStdString(cmd.email());
|
||||
if (requireEmailForRegistration && emailAddress.isEmpty())
|
||||
return EmailRequired;
|
||||
|
||||
Server_DatabaseInterface *databaseInterface = getDatabaseInterface();
|
||||
|
||||
// TODO: Move this method outside of the db interface
|
||||
QString userName = QString::fromStdString(cmd.user_name());
|
||||
if (!databaseInterface->usernameIsValid(userName))
|
||||
return InvalidUsername;
|
||||
|
||||
if (databaseInterface->checkUserIsBanned(ipAddress, userName, banReason, banSecondsRemaining))
|
||||
return ClientIsBanned;
|
||||
|
||||
if (tooManyRegistrationAttempts(ipAddress))
|
||||
return TooManyRequests;
|
||||
|
||||
QString realName = QString::fromStdString(cmd.real_name());
|
||||
ServerInfo_User_Gender gender = cmd.gender();
|
||||
QString country = QString::fromStdString(cmd.country());
|
||||
QString passwordSha512 = QString::fromStdString(cmd.password());
|
||||
bool regSucceeded = databaseInterface->registerUser(userName, realName, gender, passwordSha512, emailAddress, country, false);
|
||||
|
||||
return regSucceeded ? Accepted : Failed;
|
||||
}
|
||||
|
||||
bool Server::tooManyRegistrationAttempts(const QString &ipAddress)
|
||||
{
|
||||
// TODO: implement
|
||||
return false;
|
||||
}
|
||||
|
||||
void Server::addPersistentPlayer(const QString &userName, int roomId, int gameId, int playerId)
|
||||
{
|
||||
QWriteLocker locker(&persistentPlayersLock);
|
||||
|
||||
Reference in New Issue
Block a user