Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
602fa253
Commit
602fa253
authored
Oct 08, 2014
by
Gavin Bisesi
Browse files
Merge pull request #359 from ctrlaltca/servatrice_reguser_fixes
Servatrice reguser fixes
parents
faa66e4d
22af789c
Changes
5
Hide whitespace changes
Inline
Side-by-side
common/server.cpp
View file @
602fa253
...
...
@@ -34,7 +34,6 @@
#include
<QCoreApplication>
#include
<QThread>
#include
<QDebug>
#include
<QSettings>
Server
::
Server
(
bool
_threaded
,
QObject
*
parent
)
:
QObject
(
parent
),
threaded
(
_threaded
),
nextLocalGameId
(
0
)
...
...
@@ -132,8 +131,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.
QSettings
settings
(
"servatrice.ini"
,
QSettings
::
IniFormat
);
bool
requireReg
=
settings
.
value
(
"authentication/regonly"
,
0
).
toBool
();
bool
requireReg
=
databaseInterface
->
getRequireRegistration
();
if
(
requireReg
)
{
qDebug
(
"Login denied: registration required"
);
databaseInterface
->
unlockSessionTables
();
...
...
common/server_database_interface.h
View file @
602fa253
...
...
@@ -2,6 +2,7 @@
#define SERVER_DATABASE_INTERFACE_H
#include
<QObject>
#include
<QSettings>
#include
"server.h"
...
...
@@ -32,6 +33,8 @@ public:
virtual
void
lockSessionTables
()
{
}
virtual
void
unlockSessionTables
()
{
}
virtual
bool
userSessionExists
(
const
QString
&
/* userName */
)
{
return
false
;
}
virtual
bool
getRequireRegistration
()
{
return
false
;
}
};
#endif
servatrice/src/servatrice.cpp
View file @
602fa253
...
...
@@ -136,18 +136,22 @@ bool Servatrice::initServer()
{
serverName
=
settingsCache
->
value
(
"server/name"
,
"My Cockatrice server"
).
toString
();
serverId
=
settingsCache
->
value
(
"server/id"
,
0
).
toInt
();
bool
regServerOnly
=
settingsCache
->
value
(
"
server
/regonly"
,
0
).
toBool
();
bool
regServerOnly
=
settingsCache
->
value
(
"
authentication
/regonly"
,
0
).
toBool
();
const
QString
authenticationMethodStr
=
settingsCache
->
value
(
"authentication/method"
).
toString
();
if
(
authenticationMethodStr
==
"sql"
)
{
qDebug
()
<<
"Authenticating method: sql"
;
authenticationMethod
=
AuthenticationSql
;
}
else
if
(
authenticationMethodStr
==
"password"
)
{
qDebug
()
<<
"Authenticating method: password"
;
authenticationMethod
=
AuthenticationPassword
;
}
else
{
if
(
regServerOnly
)
{
qDebug
()
<<
"Registration only server enabled but no authentication method defined: Error."
;
return
false
;
}
qDebug
()
<<
"Authenticating method: none"
;
authenticationMethod
=
AuthenticationNone
;
}
...
...
servatrice/src/servatrice_database_interface.cpp
View file @
602fa253
...
...
@@ -89,6 +89,11 @@ bool Servatrice_DatabaseInterface::usernameIsValid(const QString &user)
return
(
result
.
size
()
>
0
);
}
bool
Servatrice_DatabaseInterface
::
getRequireRegistration
()
{
return
settingsCache
->
value
(
"authentication/regonly"
,
0
).
toBool
();
}
AuthenticationResult
Servatrice_DatabaseInterface
::
checkUserPassword
(
Server_ProtocolHandler
*
handler
,
const
QString
&
user
,
const
QString
&
password
,
QString
&
reasonStr
,
int
&
banSecondsLeft
)
{
switch
(
server
->
getAuthenticationMethod
())
{
...
...
servatrice/src/servatrice_database_interface.h
View file @
602fa253
...
...
@@ -50,7 +50,8 @@ public:
void
lockSessionTables
();
void
unlockSessionTables
();
bool
userSessionExists
(
const
QString
&
userName
);
bool
getRequireRegistration
();
};
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment