mirror of
https://github.com/SWG-Source/src.git
synced 2026-08-28 17:56:29 -04:00
no more spaces for extra secret slots - closes #34
This commit is contained in:
@@ -172,23 +172,27 @@ void ClientConnection::onReceive(const Archive::ByteStream & message)
|
||||
// originally was used to validate station API credentials, now uses our custom api
|
||||
void ClientConnection::validateClient(const std::string & id, const std::string & key)
|
||||
{
|
||||
StationId suid = atoi(id.c_str());
|
||||
// to avoid having to re-type this stupid var all over the place
|
||||
// ideally we wouldn't copy this here, but it would be a huge pain
|
||||
const std::string trimmedId = trim(id);
|
||||
|
||||
StationId suid = atoi(trimmedId.c_str());
|
||||
int authOK = 0;
|
||||
|
||||
if (suid == 0)
|
||||
{
|
||||
std::hash<std::string> h;
|
||||
suid = h(id); //lint !e603 // Symbol 'h' not initialized (it's a functor)
|
||||
suid = h(trimmedId); //lint !e603 // Symbol 'h' not initialized (it's a functor)
|
||||
}
|
||||
|
||||
LOG("LoginClientConnection", ("validateClient() for stationId (%lu) at IP (%s), id (%s)", m_stationId, getRemoteAddress().c_str(), id.c_str()));
|
||||
LOG("LoginClientConnection", ("validateClient() for stationId (%lu) at IP (%s), id (%s)", m_stationId, getRemoteAddress().c_str(), trimmedId.c_str()));
|
||||
|
||||
std::string authURL(ConfigLoginServer::getExternalAuthUrl());
|
||||
|
||||
if (!authURL.empty())
|
||||
{
|
||||
std::ostringstream postBuf;
|
||||
postBuf << "user_name=" << id << "&user_password=" << key << "&stationID=" << suid << "&ip=" << getRemoteAddress();
|
||||
postBuf << "user_name=" << trimmedId << "&user_password=" << key << "&stationID=" << suid << "&ip=" << getRemoteAddress();
|
||||
|
||||
std::string response = webAPI::simplePost(authURL, std::string(postBuf.str()), "");
|
||||
|
||||
@@ -210,7 +214,7 @@ void ClientConnection::validateClient(const std::string & id, const std::string
|
||||
|
||||
if (authOK)
|
||||
{
|
||||
LoginServer::getInstance().onValidateClient(suid, id, this, true, NULL, 0xFFFFFFFF, 0xFFFFFFFF);
|
||||
LoginServer::getInstance().onValidateClient(suid, trimmedId, this, true, NULL, 0xFFFFFFFF, 0xFFFFFFFF);
|
||||
}
|
||||
// else this case will never be reached, noop
|
||||
}
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
#include "serverUtility/ServerConnection.h"
|
||||
#include "sharedFoundation/StationId.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <string>
|
||||
|
||||
class ClientCommandChannel;
|
||||
class NetworkId;
|
||||
|
||||
@@ -68,6 +72,20 @@ private:
|
||||
|
||||
}; //lint !e1712 // default constructor not defined
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
// stolen from http://www.codeproject.com/Articles/10880/A-trim-implementation-for-std-string
|
||||
// i'm rusty and haven't gotten to lambdas yet
|
||||
inline const std::string trim(std::string str)
|
||||
{
|
||||
|
||||
str.erase(str.begin(), std::find_if(str.begin(), str.end(),
|
||||
[](char& ch)->bool { return !isspace(ch); }));
|
||||
str.erase(std::find_if(str.rbegin(), str.rend(),
|
||||
[](char& ch)->bool { return !isspace(ch); }).base(), str.end());
|
||||
return str;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const StationId ClientConnection::getStationId() const
|
||||
|
||||
Reference in New Issue
Block a user