From f32929128e1d93517f24253ed58801acc32ce814 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Wed, 30 Oct 2013 20:30:00 +0000 Subject: [PATCH] Hotfix: Authenticate all Web&ApiRequests to fix save loading/voting issues --- src/client/requestbroker/APIRequest.cpp | 11 ++++++++++- src/client/requestbroker/WebRequest.cpp | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/client/requestbroker/APIRequest.cpp b/src/client/requestbroker/APIRequest.cpp index aa42f1067..6685b428e 100644 --- a/src/client/requestbroker/APIRequest.cpp +++ b/src/client/requestbroker/APIRequest.cpp @@ -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(user.ID).c_str()); + std::strcpy(userSession, user.SessionID.c_str()); + http_auth_headers(HTTPContext, userName, NULL, userSession); + delete userSession; + } } //RequestTime = time(NULL); } diff --git a/src/client/requestbroker/WebRequest.cpp b/src/client/requestbroker/WebRequest.cpp index fffdcc804..532cda712 100644 --- a/src/client/requestbroker/WebRequest.cpp +++ b/src/client/requestbroker/WebRequest.cpp @@ -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(user.ID).c_str()); + std::strcpy(userSession, user.SessionID.c_str()); + http_auth_headers(HTTPContext, userName, NULL, userSession); + delete userSession; + } } } return RequestBroker::OK;