mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-25 16:13:54 -07:00
Reject more invalid usernames from clients.
Specifically this should cover people connecting with a username of "\u200C"
This commit is contained in:
parent
ba5669652c
commit
af09d0d294
8 changed files with 33 additions and 7 deletions
|
|
@ -9,6 +9,7 @@ message Event_ConnectionClosed {
|
|||
SERVER_SHUTDOWN = 2;
|
||||
TOO_MANY_CONNECTIONS = 3;
|
||||
BANNED = 4;
|
||||
USERNAMEINVALID = 5;
|
||||
}
|
||||
optional CloseReason reason = 1;
|
||||
optional string reason_str = 2;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ message Response {
|
|||
RespChatFlood = 18;
|
||||
RespUserIsBanned = 19;
|
||||
RespAccessDenied = 20;
|
||||
RespUsernameInvalid = 21;
|
||||
}
|
||||
enum ResponseType {
|
||||
JOIN_ROOM = 1000;
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
|
|||
QWriteLocker locker(&clientsLock);
|
||||
|
||||
AuthenticationResult authState = databaseInterface->checkUserPassword(session, name, password, reasonStr, secondsLeft);
|
||||
if ((authState == NotLoggedIn) || (authState == UserIsBanned))
|
||||
if ((authState == NotLoggedIn) || (authState == UserIsBanned || authState == UsernameInvalid))
|
||||
return authState;
|
||||
|
||||
ServerInfo_User data = databaseInterface->getUserData(name, true);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class GameEventContainer;
|
|||
class CommandContainer;
|
||||
class Command_JoinGame;
|
||||
|
||||
enum AuthenticationResult { NotLoggedIn = 0, PasswordRight = 1, UnknownUser = 2, WouldOverwriteOldSession = 3, UserIsBanned = 4 };
|
||||
enum AuthenticationResult { NotLoggedIn = 0, PasswordRight = 1, UnknownUser = 2, WouldOverwriteOldSession = 3, UserIsBanned = 4, UsernameInvalid = 5 };
|
||||
|
||||
class Server : public QObject
|
||||
{
|
||||
|
|
|
|||
|
|
@ -200,11 +200,11 @@ Response::ResponseCode Server_ProtocolHandler::processGameCommandContainer(const
|
|||
if (!game) {
|
||||
if (room->getExternalGames().contains(cont.game_id())) {
|
||||
server->sendIsl_GameCommand(cont,
|
||||
room->getExternalGames().value(cont.game_id()).server_id(),
|
||||
userInfo->session_id(),
|
||||
roomIdAndPlayerId.first,
|
||||
roomIdAndPlayerId.second
|
||||
);
|
||||
room->getExternalGames().value(cont.game_id()).server_id(),
|
||||
userInfo->session_id(),
|
||||
roomIdAndPlayerId.first,
|
||||
roomIdAndPlayerId.second
|
||||
);
|
||||
return Response::RespNothing;
|
||||
}
|
||||
return Response::RespNotInRoom;
|
||||
|
|
@ -338,6 +338,7 @@ Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd
|
|||
}
|
||||
case NotLoggedIn: return Response::RespWrongPassword;
|
||||
case WouldOverwriteOldSession: return Response::RespWouldOverwriteOldSession;
|
||||
case UsernameInvalid: return Response::RespUsernameInvalid;
|
||||
default: authState = res;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue