Registered Only Server

Implemented the ability to set the server to only allow registered
users.  Also updated client to reflect the log-in rejection as well as
put a check in place for the server to not start if db connection is not
available yet registration is required.
This commit is contained in:
woogerboy21
2014-07-02 20:52:22 -04:00
parent fb4a7b3274
commit d246fa39fe
7 changed files with 27 additions and 6 deletions

View File

@@ -34,6 +34,7 @@
#include <QCoreApplication>
#include <QThread>
#include <QDebug>
#include <QSettings>
Server::Server(bool _threaded, QObject *parent)
: QObject(parent), threaded(_threaded), nextLocalGameId(0)
@@ -131,6 +132,14 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
} else if (authState == UnknownUser) {
// Change user name so that no two users have the same names,
// don't interfere with registered user names though.
QSettings *settings = new QSettings("servatrice.ini", QSettings::IniFormat);
bool requireReg = settings->value("server/regonly").toBool();
if (requireReg) {
qDebug("Login denied: registration required");
databaseInterface->unlockSessionTables();
return RegistrationRequired;
}
QString tempName = name;
int i = 0;
while (users.contains(tempName) || databaseInterface->userExists(tempName) || databaseInterface->userSessionExists(tempName))