mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-01 23:46:59 +00:00
Merge pull request #105 from WiserTixx/id-from-auth
Send id from auth to game
This commit is contained in:
commit
a60ff48c08
@ -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));
|
||||
|
@ -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!");
|
||||
|
Loading…
x
Reference in New Issue
Block a user