45 .WithPreparedCallback([sess = shared_from_this()](
PreparedQueryResult result) { sess->CheckIpCallback(std::move(result)); }));
55 Field* fields = result->Fetch();
56 if (fields[0].GetUInt64() != 0)
59 }
while (result->NextRow());
74 return sLoginService.HandleRequest(shared_from_this(), context);
79 using namespace std::string_literals;
81 std::shared_ptr<Trinity::Net::Http::SessionState> state;
83 auto cookieItr = context.
request.find(boost::beast::http::field::cookie);
84 if (cookieItr != context.
request.end())
88 auto sessionIdItr = std::find_if(cookies.begin(), cookies.end(), [&](std::string_view cookie)
90 std::string_view name = cookie;
91 eq = cookie.find(
'=');
92 if (eq != std::string_view::npos)
93 name = cookie.substr(0, eq);
95 return name == SESSION_ID_COOKIE;
97 if (sessionIdItr != cookies.end())
99 std::string_view value = sessionIdItr->substr(eq + 1);
109 if (std::size_t port = host.find(
':'); port != std::string_view::npos)
110 host.remove_suffix(host.length() - port);
112 context.
response.insert(boost::beast::http::field::set_cookie,
Trinity::StringFormat(
"{}={}; Path=/bnetserver; Domain={}; Secure; HttpOnly; SameSite=None",
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
#define TC_LOG_DEBUG(filterType__,...)
#define TC_LOG_TRACE(filterType__,...)
@ LOGIN_DEL_EXPIRED_IP_BANS
T & AddCallback(T &&query)
Trinity::Net::Http::RequestHandlerResult RequestHandler(Trinity::Net::Http::RequestContext &context) override
LoginHttpSession(boost::asio::ip::tcp::socket &&socket)
static constexpr std::string_view SESSION_ID_COOKIE
void CheckIpCallback(PreparedQueryResult result)
std::shared_ptr< Trinity::Net::Http::SessionState > ObtainSessionState(Trinity::Net::Http::RequestContext &context) const override
Class used to access individual fields of database query result.
void setString(const uint8 index, const std::string &value)
boost::asio::ip::address GetRemoteIpAddress() const
QueryCallbackProcessor _queryProcessor
std::string GetClientInfo() const override
std::string_view ToStdStringView(boost::beast::string_view bsw)
TC_COMMON_API std::vector< std::string_view > Tokenize(std::string_view str, char sep, bool keepEmpty)
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default TC string format function.