mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 16:24:45 -07:00
improved banning; added [url] and [card] tags for chat
This commit is contained in:
parent
4b84168bda
commit
05ebb83ba4
36 changed files with 2501 additions and 2073 deletions
|
|
@ -484,11 +484,12 @@ Command_ShutdownServer::Command_ShutdownServer(const QString &_reason, int _minu
|
|||
insertItem(new SerializableItem_String("reason", _reason));
|
||||
insertItem(new SerializableItem_Int("minutes", _minutes));
|
||||
}
|
||||
Command_BanFromServer::Command_BanFromServer(const QString &_userName, int _minutes)
|
||||
Command_BanFromServer::Command_BanFromServer(const QString &_userName, int _minutes, const QString &_reason)
|
||||
: ModeratorCommand("ban_from_server")
|
||||
{
|
||||
insertItem(new SerializableItem_String("user_name", _userName));
|
||||
insertItem(new SerializableItem_Int("minutes", _minutes));
|
||||
insertItem(new SerializableItem_String("reason", _reason));
|
||||
}
|
||||
void ProtocolItem::initializeHashAuto()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -80,4 +80,4 @@
|
|||
6:mulligan:i,number
|
||||
7:update_server_message
|
||||
7:shutdown_server:s,reason:i,minutes
|
||||
8:ban_from_server:s,user_name:i,minutes
|
||||
8:ban_from_server:s,user_name:i,minutes:s,reason
|
||||
|
|
@ -735,9 +735,10 @@ public:
|
|||
class Command_BanFromServer : public ModeratorCommand {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Command_BanFromServer(const QString &_userName = QString(), int _minutes = -1);
|
||||
Command_BanFromServer(const QString &_userName = QString(), int _minutes = -1, const QString &_reason = QString());
|
||||
QString getUserName() const { return static_cast<SerializableItem_String *>(itemMap.value("user_name"))->getData(); };
|
||||
int getMinutes() const { return static_cast<SerializableItem_Int *>(itemMap.value("minutes"))->getData(); };
|
||||
QString getReason() const { return static_cast<SerializableItem_String *>(itemMap.value("reason"))->getData(); };
|
||||
static SerializableItem *newItem() { return new Command_BanFromServer; }
|
||||
int getItemId() const { return ItemId_Command_BanFromServer; }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
|
|||
QMutexLocker locker(&serverMutex);
|
||||
if (name.size() > 35)
|
||||
name = name.left(35);
|
||||
AuthenticationResult authState = checkUserPassword(name, password);
|
||||
AuthenticationResult authState = checkUserPassword(session, name, password);
|
||||
if (authState == PasswordWrong)
|
||||
return authState;
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ public:
|
|||
|
||||
virtual QMap<QString, ServerInfo_User *> getBuddyList(const QString &name) = 0;
|
||||
virtual QMap<QString, ServerInfo_User *> getIgnoreList(const QString &name) = 0;
|
||||
virtual bool getUserBanned(Server_ProtocolHandler * /*client*/, const QString & /*userName*/) const { return false; }
|
||||
protected:
|
||||
void prepareDestroy();
|
||||
QList<Server_ProtocolHandler *> clients;
|
||||
|
|
@ -51,7 +50,7 @@ protected:
|
|||
QMap<int, Server_Room *> rooms;
|
||||
|
||||
virtual bool userExists(const QString &user) = 0;
|
||||
virtual AuthenticationResult checkUserPassword(const QString &user, const QString &password) = 0;
|
||||
virtual AuthenticationResult checkUserPassword(Server_ProtocolHandler *handler, const QString &user, const QString &password) = 0;
|
||||
virtual ServerInfo_User *getUserData(const QString &name) = 0;
|
||||
int getUsersCount() const;
|
||||
int getGamesCount() const;
|
||||
|
|
|
|||
|
|
@ -280,8 +280,6 @@ ResponseCode Server_ProtocolHandler::cmdLogin(Command_Login *cmd, CommandContain
|
|||
QString userName = cmd->getUsername().simplified();
|
||||
if (userName.isEmpty() || (userInfo != 0))
|
||||
return RespContextError;
|
||||
if (server->getUserBanned(this, userName))
|
||||
return RespWrongPassword;
|
||||
authState = server->loginUser(this, userName, cmd->getPassword());
|
||||
if (authState == PasswordWrong)
|
||||
return RespWrongPassword;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue