From 7c1106a46a14027c69e4a5399072d67526539715 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Fri, 9 Feb 2024 14:24:41 +0100 Subject: [PATCH] add username to auth packet --- src/Network/Core.cpp | 3 ++- src/Security/Login.cpp | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Network/Core.cpp b/src/Network/Core.cpp index 2b21ea9..1ebe695 100755 --- a/src/Network/Core.cpp +++ b/src/Network/Core.cpp @@ -24,6 +24,7 @@ bool TCPTerminate = false; int DEFAULT_PORT = 4444; bool Terminate = false; bool LoginAuth = false; +std::string Username = ""; std::string UlStatus; std::string MStatus; bool ModLoaded; @@ -126,7 +127,7 @@ void Parse(std::string Data,SOCKET CSocket){ break; case 'N': if (SubCode == 'c'){ - Data = "N{\"Auth\":"+std::to_string(LoginAuth)+"}"; + Data = "N{\"Auth\":"+std::to_string(LoginAuth)+",\"username\":\"" + Username + "\"}"; }else{ Data = "N" + Login(Data.substr(Data.find(':') + 1)); } diff --git a/src/Security/Login.cpp b/src/Security/Login.cpp index bbb9051..ad8b11a 100755 --- a/src/Security/Login.cpp +++ b/src/Security/Login.cpp @@ -17,6 +17,7 @@ namespace fs = std::filesystem; std::string PublicKey; std::string PrivateKey; extern bool LoginAuth; +extern std::string Username; std::string Role; void UpdateKey(const char* newKey){ @@ -64,6 +65,9 @@ std::string Login(const std::string& fields){ } if(d.contains("success") && d["success"].get()){ LoginAuth = true; + if (d.contains("username")) { + Username = d["username"].get(); + } if(!d.contains("private_key")) { UpdateKey(d["private_key"].get().c_str()); }