mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-03 08:26:01 +00:00
print error when throwing exception in auth
This commit is contained in:
parent
5db1b48e07
commit
b2e5b8d2d3
@ -51,37 +51,41 @@ std::string Login(const std::string& fields){
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
info("Attempting to authenticate...");
|
info("Attempting to authenticate...");
|
||||||
std::string Buffer = HTTP::Post("https://auth.beammp.com/userlogin", fields);
|
try {
|
||||||
|
std::string Buffer = HTTP::Post("https://auth.beammp.com/userlogin", fields);
|
||||||
|
|
||||||
if(Buffer == "-1"){
|
if(Buffer == "-1"){
|
||||||
return GetFail("Failed to communicate with the auth system!");
|
return GetFail("Failed to communicate with the auth system!");
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json d = nlohmann::json::parse(Buffer, nullptr, false);
|
nlohmann::json d = nlohmann::json::parse(Buffer, nullptr, false);
|
||||||
|
|
||||||
if (Buffer.at(0) != '{' || d.is_discarded()) {
|
if (Buffer.at(0) != '{' || d.is_discarded()) {
|
||||||
error(Buffer);
|
error(Buffer);
|
||||||
return GetFail("Invalid answer from authentication servers, please try again later!");
|
return GetFail("Invalid answer from authentication servers, please try again later!");
|
||||||
|
}
|
||||||
|
if(d.contains("success") && d["success"].get<bool>()){
|
||||||
|
LoginAuth = true;
|
||||||
|
if (d.contains("username")) {
|
||||||
|
Username = d["username"].get<std::string>();
|
||||||
|
}
|
||||||
|
if(!d.contains("private_key")) {
|
||||||
|
UpdateKey(d["private_key"].get<std::string>().c_str());
|
||||||
|
}
|
||||||
|
if(!d.contains("public_key")){
|
||||||
|
PublicKey = d["public_key"].get<std::string>();
|
||||||
|
}
|
||||||
|
info("Authentication successful!");
|
||||||
|
}else info("Authentication failed!");
|
||||||
|
if(!d.contains("message")){
|
||||||
|
d.erase("private_key");
|
||||||
|
d.erase("public_key");
|
||||||
|
return d.dump();
|
||||||
|
}
|
||||||
|
return GetFail("Invalid message parsing!");
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
error(e.what());
|
||||||
}
|
}
|
||||||
if(d.contains("success") && d["success"].get<bool>()){
|
|
||||||
LoginAuth = true;
|
|
||||||
if (d.contains("username")) {
|
|
||||||
Username = d["username"].get<std::string>();
|
|
||||||
}
|
|
||||||
if(!d.contains("private_key")) {
|
|
||||||
UpdateKey(d["private_key"].get<std::string>().c_str());
|
|
||||||
}
|
|
||||||
if(!d.contains("public_key")){
|
|
||||||
PublicKey = d["public_key"].get<std::string>();
|
|
||||||
}
|
|
||||||
info("Authentication successful!");
|
|
||||||
}else info("Authentication failed!");
|
|
||||||
if(!d.contains("message")){
|
|
||||||
d.erase("private_key");
|
|
||||||
d.erase("public_key");
|
|
||||||
return d.dump();
|
|
||||||
}
|
|
||||||
return GetFail("Invalid message parsing!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckLocalKey(){
|
void CheckLocalKey(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user