Fix multiple sessions being created for some users

If a user didn't have send-data activated they don't have their session id
sent in the header of requests, but instead send it inside the request
body. The session id being send in the request included curly braces which
the server considers invalid.
This commit is contained in:
Ryan Huffman 2016-06-30 14:35:27 -07:00
parent 925aea162a
commit 38776fe007
2 changed files with 5 additions and 4 deletions

View file

@ -80,8 +80,7 @@ void DiscoverabilityManager::updateLocation() {
locationObject.insert(FRIENDS_ONLY_KEY_IN_LOCATION, (_mode.get() == Discoverability::Friends));
// if we have a session ID add it now, otherwise add a null value
auto sessionID = accountManager->getSessionID();
rootObject[SESSION_ID_KEY] = sessionID.isNull() ? QJsonValue() : sessionID.toString();
rootObject[SESSION_ID_KEY] = accountManager->getSessionIDWithoutCurlyBraces();
JSONCallbackParameters callbackParameters;
callbackParameters.jsonCallbackReceiver = this;
@ -111,8 +110,7 @@ void DiscoverabilityManager::updateLocation() {
callbackParameters.jsonCallbackMethod = "handleHeartbeatResponse";
QJsonObject heartbeatObject;
auto sessionID = accountManager->getSessionID();
heartbeatObject[SESSION_ID_KEY] = sessionID.isNull() ? QJsonValue() : sessionID.toString();
heartbeatObject[SESSION_ID_KEY] = accountManager->getSessionIDWithoutCurlyBraces();
accountManager->sendRequest(API_USER_HEARTBEAT_PATH, AccountManagerAuth::Optional,
QNetworkAccessManager::PutOperation, callbackParameters,

View file

@ -24,6 +24,8 @@
#include <DependencyManager.h>
#include "UUID.h"
class JSONCallbackParameters {
public:
JSONCallbackParameters(QObject* jsonCallbackReceiver = nullptr, const QString& jsonCallbackMethod = QString(),
@ -86,6 +88,7 @@ public:
static QJsonObject dataObjectFromResponse(QNetworkReply& requestReply);
QString getSessionIDWithoutCurlyBraces() const { return uuidStringWithoutCurlyBraces(_sessionID); }
QUuid getSessionID() const { return _sessionID; }
void setSessionID(const QUuid& sessionID) { _sessionID = sessionID; }