mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-21 14:50:26 -08:00
Initial release of client ID generation.
This commit is contained in:
@@ -103,7 +103,7 @@ Server_DatabaseInterface *Server::getDatabaseInterface() const
|
||||
return databaseInterfaces.value(QThread::currentThread());
|
||||
}
|
||||
|
||||
AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString &name, const QString &password, QString &reasonStr, int &secondsLeft)
|
||||
AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString &name, const QString &password, QString &reasonStr, int &secondsLeft, QString &clientid)
|
||||
{
|
||||
if (name.size() > 35)
|
||||
name = name.left(35);
|
||||
@@ -123,6 +123,8 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
|
||||
databaseInterface->lockSessionTables();
|
||||
|
||||
if (authState == PasswordRight) {
|
||||
|
||||
// verify that new session would not cause problems with older existing session
|
||||
if (users.contains(name) || databaseInterface->userSessionExists(name)) {
|
||||
qDebug("Login denied: would overwrite old session");
|
||||
databaseInterface->unlockSessionTables();
|
||||
@@ -168,6 +170,15 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
|
||||
event.mutable_user_info()->CopyFrom(session->copyUserInfo(true, true, true));
|
||||
locker.unlock();
|
||||
|
||||
// check if client id exists (older client compatibility)
|
||||
if (clientid.isEmpty()){
|
||||
// client id is empty, either out dated client or client has been modified
|
||||
}
|
||||
else {
|
||||
// update users database table with client id
|
||||
databaseInterface->updateUsersClientID(name, clientid);
|
||||
}
|
||||
|
||||
se = Server_ProtocolHandler::prepareSessionEvent(event);
|
||||
sendIsl_SessionEvent(*se);
|
||||
delete se;
|
||||
|
||||
Reference in New Issue
Block a user