mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-17 22:51:30 +00:00
API adjustments
This commit is contained in:
parent
f06ff14f9e
commit
f39684b7f7
@ -242,15 +242,16 @@ bool AccountManagement::UpdateLoginserverUserCredentials(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AccountManagement::CheckExternalLoginserverUserCredentials(
|
uint32 AccountManagement::CheckExternalLoginserverUserCredentials(
|
||||||
const std::string &in_account_username,
|
const std::string &in_account_username,
|
||||||
const std::string &in_account_password
|
const std::string &in_account_password
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
auto res = task_runner.Enqueue(
|
auto res = task_runner.Enqueue(
|
||||||
[&]() -> bool {
|
[&]() -> uint32 {
|
||||||
bool running = true;
|
bool running = true;
|
||||||
bool ret = false;
|
uint32 ret = 0;
|
||||||
|
|
||||||
EQ::Net::DaybreakConnectionManager mgr;
|
EQ::Net::DaybreakConnectionManager mgr;
|
||||||
std::shared_ptr<EQ::Net::DaybreakConnection> c;
|
std::shared_ptr<EQ::Net::DaybreakConnection> c;
|
||||||
|
|
||||||
@ -286,6 +287,7 @@ bool AccountManagement::CheckExternalLoginserverUserCredentials(
|
|||||||
{
|
{
|
||||||
size_t buffer_len =
|
size_t buffer_len =
|
||||||
in_account_username.length() + in_account_password.length() + 2;
|
in_account_username.length() + in_account_password.length() + 2;
|
||||||
|
|
||||||
std::unique_ptr<char[]> buffer(new char[buffer_len]);
|
std::unique_ptr<char[]> buffer(new char[buffer_len]);
|
||||||
|
|
||||||
strcpy(&buffer[0], in_account_username.c_str());
|
strcpy(&buffer[0], in_account_username.c_str());
|
||||||
@ -318,9 +320,10 @@ bool AccountManagement::CheckExternalLoginserverUserCredentials(
|
|||||||
|
|
||||||
EQ::Net::StaticPacket sp(&decrypted[0], encrypt_size);
|
EQ::Net::StaticPacket sp(&decrypted[0], encrypt_size);
|
||||||
auto response_error = sp.GetUInt16(1);
|
auto response_error = sp.GetUInt16(1);
|
||||||
|
auto m_dbid = sp.GetUInt32(8);
|
||||||
|
|
||||||
{
|
{
|
||||||
ret = response_error <= 101;
|
ret = (response_error <= 101 ? m_dbid : 0);
|
||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -332,7 +335,7 @@ bool AccountManagement::CheckExternalLoginserverUserCredentials(
|
|||||||
EQ::Net::DNSLookup(
|
EQ::Net::DNSLookup(
|
||||||
"login.eqemulator.net", 5999, false, [&](const std::string &addr) {
|
"login.eqemulator.net", 5999, false, [&](const std::string &addr) {
|
||||||
if (addr.empty()) {
|
if (addr.empty()) {
|
||||||
ret = false;
|
ret = 0;
|
||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -76,7 +76,7 @@ public:
|
|||||||
* @param in_account_password
|
* @param in_account_password
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static bool CheckExternalLoginserverUserCredentials(
|
static uint32 CheckExternalLoginserverUserCredentials(
|
||||||
const std::string &in_account_username,
|
const std::string &in_account_username,
|
||||||
const std::string &in_account_password
|
const std::string &in_account_password
|
||||||
);
|
);
|
||||||
|
|||||||
@ -191,13 +191,14 @@ namespace LoginserverWebserver {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool credentials_valid = AccountManagement::CheckExternalLoginserverUserCredentials(
|
uint32 account_id = AccountManagement::CheckExternalLoginserverUserCredentials(
|
||||||
username,
|
username,
|
||||||
password
|
password
|
||||||
);
|
);
|
||||||
|
|
||||||
if (credentials_valid) {
|
if (account_id > 0) {
|
||||||
response["message"] = "Credentials valid!";
|
response["message"] = "Credentials valid!";
|
||||||
|
response["data"]["account_id"] = account_id;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
response["error"] = "Credentials invalid!";
|
response["error"] = "Credentials invalid!";
|
||||||
@ -246,7 +247,7 @@ namespace LoginserverWebserver {
|
|||||||
ss.str(request.body);
|
ss.str(request.body);
|
||||||
ss >> request_body;
|
ss >> request_body;
|
||||||
}
|
}
|
||||||
catch (std::exception&) {
|
catch (std::exception &) {
|
||||||
request_body["error"] = "Payload invalid";
|
request_body["error"] = "Payload invalid";
|
||||||
|
|
||||||
return request_body;
|
return request_body;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user