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:
Gavin Bises
2015-02-21 21:29:59 -05:00
committed by Fabio Bas
parent d1b243481b
commit 735fcbf311
16 changed files with 394 additions and 48 deletions

View File

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