Hotfix: Authenticate all Web&ApiRequests to fix save loading/voting issues

This commit is contained in:
Simon Robertshaw 2013-10-30 20:30:00 +00:00
parent 67c82ee283
commit f32929128e
2 changed files with 20 additions and 1 deletions

View File

@ -97,7 +97,6 @@ RequestBroker::ProcessResponse APIRequest::Process(RequestBroker & rb)
if(Client::Ref().GetAuthUser().ID)
{
std::cout << typeid(*this).name() << " Authenticated " << std::endl;
User user = Client::Ref().GetAuthUser();
char userName[12];
char *userSession = new char[user.SessionID.length() + 1];
@ -115,6 +114,16 @@ RequestBroker::ProcessResponse APIRequest::Process(RequestBroker & rb)
else
{
HTTPContext = http_async_req_start(NULL, (char *)URL.c_str(), NULL, 0, 0);
if(Client::Ref().GetAuthUser().ID)
{
User user = Client::Ref().GetAuthUser();
char userName[12];
char *userSession = new char[user.SessionID.length() + 1];
std::strcpy(userName, format::NumberToString<int>(user.ID).c_str());
std::strcpy(userSession, user.SessionID.c_str());
http_auth_headers(HTTPContext, userName, NULL, userSession);
delete userSession;
}
}
//RequestTime = time(NULL);
}

View File

@ -114,6 +114,16 @@ RequestBroker::ProcessResponse WebRequest::Process(RequestBroker & rb)
else
{
HTTPContext = http_async_req_start(NULL, (char *)URL.c_str(), NULL, 0, 0);
if(Client::Ref().GetAuthUser().ID)
{
User user = Client::Ref().GetAuthUser();
char userName[12];
char *userSession = new char[user.SessionID.length() + 1];
std::strcpy(userName, format::NumberToString<int>(user.ID).c_str());
std::strcpy(userSession, user.SessionID.c_str());
http_auth_headers(HTTPContext, userName, NULL, userSession);
delete userSession;
}
}
}
return RequestBroker::OK;