Async eqemu login credential lookup

This commit is contained in:
KimLS
2019-08-08 18:45:10 -07:00
parent 880de837d9
commit 6a64d845c2
6 changed files with 291 additions and 2 deletions
+31 -1
View File
@@ -158,6 +158,36 @@ namespace LoginserverWebserver {
LoginserverWebserver::SendResponse(response, res);
}
);
api.Post(
"/account/credentials/validate/external", [](const httplib::Request &request, httplib::Response &res) {
LoginserverWebserver::TokenManager::AuthCanRead(request, res);
Json::Value request_body = LoginserverWebserver::ParseRequestBody(request);
std::string username = request_body.get("username", "").asString();
std::string password = request_body.get("password", "").asString();
Json::Value response;
if (username.empty() || password.empty()) {
response["error"] = "Username or password not set";
LoginserverWebserver::SendResponse(response, res);
return;
}
bool credentials_valid = AccountManagement::CheckExternalLoginserverUserCredentials(
username,
password
);
if (credentials_valid) {
response["message"] = "Credentials valid!";
}
else {
response["error"] = "Credentials invalid!";
}
LoginserverWebserver::SendResponse(response, res);
}
);
}
/**
@@ -351,4 +381,4 @@ namespace LoginserverWebserver {
return {};
}
}
}