Moved the RegOnlyRequirement functions out of the Database interface into the proper Server block of code.
This commit is contained in:
parent
129a6983ed
commit
17392f1ae5
7 changed files with 125 additions and 131 deletions
|
@ -133,8 +133,7 @@ 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.
|
||||
bool requireReg = databaseInterface->getRequireRegistration();
|
||||
if (requireReg) {
|
||||
if (getRegOnlyServer()) {
|
||||
qDebug("Login denied: registration required");
|
||||
databaseInterface->unlockSessionTables();
|
||||
return RegistrationRequired;
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
|
||||
virtual bool getGameShouldPing() const { return false; }
|
||||
virtual bool getClientIdRequired() const { return false; }
|
||||
virtual bool getRegOnlyServer() const { return false; }
|
||||
virtual int getPingClockInterval() const { return 0; }
|
||||
virtual int getMaxGameInactivityTime() const { return 9999999; }
|
||||
virtual int getMaxPlayerInactivityTime() const { return 9999999; }
|
||||
|
|
|
@ -62,8 +62,8 @@ method=none
|
|||
; if the chosen authentication method is password, here you can define the password your users will use to log in
|
||||
password=123456
|
||||
|
||||
; Accept only registered users? default is 0 (accept unregistered users)
|
||||
regonly=0
|
||||
; Accept only registered users? default is false (accept unregistered users)
|
||||
regonly=false
|
||||
|
||||
[users]
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ bool Servatrice::initServer()
|
|||
serverName = settingsCache->value("server/name", "My Cockatrice server").toString();
|
||||
serverId = settingsCache->value("server/id", 0).toInt();
|
||||
clientIdRequired = settingsCache->value("server/requireclientid",0).toBool();
|
||||
bool regServerOnly = settingsCache->value("authentication/regonly", 0).toBool();
|
||||
regServerOnly = settingsCache->value("authentication/regonly", 0).toBool();
|
||||
|
||||
const QString authenticationMethodStr = settingsCache->value("authentication/method").toString();
|
||||
if (authenticationMethodStr == "sql") {
|
||||
|
@ -174,7 +174,7 @@ bool Servatrice::initServer()
|
|||
bool registrationEnabled = settingsCache->value("registration/enabled", false).toBool();
|
||||
bool requireEmailForRegistration = settingsCache->value("registration/requireemail", true).toBool();
|
||||
|
||||
qDebug() << "Registration enabled: " << registrationEnabled;
|
||||
qDebug() << "Registration enabled: " << regServerOnly;
|
||||
if (registrationEnabled)
|
||||
qDebug() << "Require email address to register: " << requireEmailForRegistration;
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ private:
|
|||
QString shutdownReason;
|
||||
int shutdownMinutes;
|
||||
QTimer *shutdownTimer;
|
||||
bool isFirstShutdownMessage, clientIdRequired;
|
||||
bool isFirstShutdownMessage, clientIdRequired, regServerOnly;
|
||||
|
||||
mutable QMutex serverListMutex;
|
||||
QList<ServerProperties> serverList;
|
||||
|
@ -138,6 +138,7 @@ public:
|
|||
QString getLoginMessage() const { QMutexLocker locker(&loginMessageMutex); return loginMessage; }
|
||||
bool getGameShouldPing() const { return true; }
|
||||
bool getClientIdRequired() const { return clientIdRequired; }
|
||||
bool getRegOnlyServer() const { return regServerOnly; }
|
||||
int getPingClockInterval() const { return pingClockInterval; }
|
||||
int getMaxGameInactivityTime() const { return maxGameInactivityTime; }
|
||||
int getMaxPlayerInactivityTime() const { return maxPlayerInactivityTime; }
|
||||
|
|
|
@ -152,12 +152,6 @@ bool Servatrice_DatabaseInterface::usernameIsValid(const QString &user, QString
|
|||
return re.exactMatch(user);
|
||||
}
|
||||
|
||||
// TODO move this to Server
|
||||
bool Servatrice_DatabaseInterface::getRequireRegistration()
|
||||
{
|
||||
return settingsCache->value("authentication/regonly", 0).toBool();
|
||||
}
|
||||
|
||||
bool Servatrice_DatabaseInterface::registerUser(const QString &userName, const QString &realName, ServerInfo_User_Gender const &gender, const QString &password, const QString &emailAddress, const QString &country, QString &token, bool active)
|
||||
{
|
||||
if (!checkSql())
|
||||
|
|
|
@ -68,7 +68,6 @@ public:
|
|||
bool usernameIsValid(const QString &user, QString & error);
|
||||
bool checkUserIsBanned(const QString &ipAddress, const QString &userName, QString &banReason, int &banSecondsRemaining);
|
||||
|
||||
bool getRequireRegistration();
|
||||
bool registerUser(const QString &userName, const QString &realName, ServerInfo_User_Gender const &gender,
|
||||
const QString &password, const QString &emailAddress, const QString &country, QString &token, bool active = false);
|
||||
bool activateUser(const QString &userName, const QString &token);
|
||||
|
|
Loading…
Reference in a new issue