From e505874af9c4f744a4756a98063c5909a6dbe27f Mon Sep 17 00:00:00 2001 From: Tixx <83774803+WiserTixx@users.noreply.github.com> Date: Sun, 11 Aug 2024 11:39:14 +0200 Subject: [PATCH] Send id from auth to game --- src/Network/Core.cpp | 4 ++++ src/Security/Login.cpp | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/Network/Core.cpp b/src/Network/Core.cpp index 0c51f88..561b9c6 100644 --- a/src/Network/Core.cpp +++ b/src/Network/Core.cpp @@ -39,6 +39,7 @@ bool Terminate = false; bool LoginAuth = false; std::string Username = ""; std::string UserRole = ""; +int UserID = -1; std::string UlStatus; std::string MStatus; bool ModLoaded; @@ -180,6 +181,9 @@ void Parse(std::string Data, SOCKET CSocket) { if (!UserRole.empty()) { Auth["role"] = UserRole; } + if (UserID != -1) { + Auth["id"] = UserID; + } Data = "N" + Auth.dump(); } else { Data = "N" + Login(Data.substr(Data.find(':') + 1)); diff --git a/src/Security/Login.cpp b/src/Security/Login.cpp index 8fbf15a..cfd6a24 100644 --- a/src/Security/Login.cpp +++ b/src/Security/Login.cpp @@ -18,6 +18,7 @@ std::string PrivateKey; extern bool LoginAuth; extern std::string Username; extern std::string UserRole; +extern int UserID; void UpdateKey(const char* newKey) { if (newKey && std::isalnum(newKey[0])) { @@ -48,6 +49,7 @@ std::string Login(const std::string& fields) { if (fields == "LO") { Username = ""; UserRole = ""; + UserID = -1; LoginAuth = false; UpdateKey(nullptr); return ""; @@ -74,6 +76,9 @@ std::string Login(const std::string& fields) { if (d.contains("role")) { UserRole = d["role"].get(); } + if (d.contains("id")) { + UserID = d["id"].get(); + } if (d.contains("private_key")) { UpdateKey(d["private_key"].get().c_str()); } @@ -129,6 +134,9 @@ void CheckLocalKey() { if (d.contains("role")) { UserRole = d["role"].get(); } + if (d.contains("id")) { + UserID = d["id"].get(); + } // info(Role); } else { info("Auto-Authentication unsuccessful please re-login!");