mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
[Loginserver] Update ticket login table structure (#3703)
* Updates login table to support tickets in a way that makes more sense. * Change to snake_case as requested by Akka --------- Co-authored-by: KimLS <KimLS@peqtgc.com>
This commit is contained in:
parent
4c8d68c24b
commit
2bd94ab7a2
@ -121,43 +121,25 @@ bool Database::GetLoginTokenDataFromToken(
|
||||
std::string &user
|
||||
)
|
||||
{
|
||||
auto query = fmt::format(
|
||||
"SELECT tbllogintokens.Id, tbllogintokens.IpAddress, tbllogintokenclaims.Name, tbllogintokenclaims.Value FROM tbllogintokens "
|
||||
"JOIN tbllogintokenclaims ON tbllogintokens.Id = tbllogintokenclaims.TokenId WHERE tbllogintokens.Expires > NOW() "
|
||||
"AND tbllogintokens.Id='{0}' AND tbllogintokens.IpAddress='{1}'",
|
||||
auto query = fmt::format("SELECT login_server, username, account_id FROM login_tickets WHERE expires > NOW()"
|
||||
" AND id='{0}' AND ip_address='{1}' LIMIT 1",
|
||||
Strings::Escape(token),
|
||||
Strings::Escape(ip)
|
||||
);
|
||||
Strings::Escape(ip));
|
||||
|
||||
auto results = QueryDatabase(query);
|
||||
if (results.RowCount() == 0 || !results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool found_username = false;
|
||||
bool found_login_id = false;
|
||||
bool found_login_server_name = false;
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
if (strcmp(row[2], "username") == 0) {
|
||||
user = row[3];
|
||||
found_username = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(row[2], "login_server_id") == 0) {
|
||||
db_account_id = Strings::ToUnsignedInt(row[3]);
|
||||
found_login_id = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(row[2], "login_server_name") == 0) {
|
||||
db_loginserver = row[3];
|
||||
found_login_server_name = true;
|
||||
continue;
|
||||
}
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
db_loginserver = row[0];
|
||||
user = row[1];
|
||||
db_account_id = Strings::ToUnsignedInt(row[2]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return found_username && found_login_id && found_login_server_name;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
11
loginserver/login_util/login_tickets.sql
Normal file
11
loginserver/login_util/login_tickets.sql
Normal file
@ -0,0 +1,11 @@
|
||||
DROP TABLE IF EXISTS `login_tickets`;
|
||||
CREATE TABLE `login_tickets` (
|
||||
`id` VARCHAR(128) NOT NULL,
|
||||
`login_server` TEXT NOT NULL,
|
||||
`username` TEXT NOT NULL,
|
||||
`account_id` INT(10) UNSIGNED NOT NULL,
|
||||
`ip_address` VARCHAR(45) NOT NULL,
|
||||
`expires` DATETIME NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
)
|
||||
ENGINE=InnoDB;
|
||||
Loading…
x
Reference in New Issue
Block a user