forward user's role on login

This commit is contained in:
Lion Kortlepel 2024-02-09 15:09:41 +01:00 committed by Lion
parent 7967ec38e8
commit aeb167c1e8
2 changed files with 6 additions and 1 deletions

View File

@ -25,6 +25,7 @@ int DEFAULT_PORT = 4444;
bool Terminate = false;
bool LoginAuth = false;
std::string Username = "";
std::string UserRole = "";
std::string UlStatus;
std::string MStatus;
bool ModLoaded;
@ -127,7 +128,7 @@ void Parse(std::string Data,SOCKET CSocket){
break;
case 'N':
if (SubCode == 'c'){
Data = "N{\"Auth\":"+std::to_string(LoginAuth)+",\"username\":\"" + Username + "\"}";
Data = "N{\"Auth\":"+std::to_string(LoginAuth)+",\"username\":\"" + Username + "\",\"role\":\"" + UserRole + "\"}";
}else{
Data = "N" + Login(Data.substr(Data.find(':') + 1));
}

View File

@ -18,6 +18,7 @@ std::string PublicKey;
std::string PrivateKey;
extern bool LoginAuth;
extern std::string Username;
extern std::string UserRole;
std::string Role;
void UpdateKey(const char* newKey){
@ -69,6 +70,9 @@ std::string Login(const std::string& fields){
if (d.contains("username")) {
Username = d["username"].get<std::string>();
}
if (d.contains("role")) {
UserRole = d["role"].get<std::string>();
}
if(d.contains("private_key")) {
UpdateKey(d["private_key"].get<std::string>().c_str());
}