Merge pull request #105 from WiserTixx/id-from-auth

Send id from auth to game
This commit is contained in:
Lion 2024-08-17 20:34:19 +02:00 committed by GitHub
commit a60ff48c08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -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));

View File

@ -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<std::string>();
}
if (d.contains("id")) {
UserID = d["id"].get<int>();
}
if (d.contains("private_key")) {
UpdateKey(d["private_key"].get<std::string>().c_str());
}
@ -129,6 +134,9 @@ void CheckLocalKey() {
if (d.contains("role")) {
UserRole = d["role"].get<std::string>();
}
if (d.contains("id")) {
UserID = d["id"].get<int>();
}
// info(Role);
} else {
info("Auto-Authentication unsuccessful please re-login!");