add a class to hold web session data

This commit is contained in:
Stephen Birarda 2014-07-21 17:23:57 -07:00
parent 1903fff45c
commit e75ed2c4fa
2 changed files with 57 additions and 0 deletions

View file

@ -0,0 +1,26 @@
//
// DomainServerWebSessionData.cpp
// domain-server/src
//
// Created by Stephen Birarda on 2014-07-21.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include <QtCore/QJsonDocument>
#include <QtCore/QJsonObject>
#include "DomainServerWebSessionData.h"
DomainServerWebSessionData::DomainServerWebSessionData(const QJsonDocument& profileDocument) :
_roles()
{
_username = profileDocument.object()["user"].toObject()["username"].toString();
// pull each of the roles and throw them into our set
foreach(const QJsonValue& rolesValue, profileDocument.object()["user"].toObject()["roles"].toObject()) {
_roles.insert(rolesValue.toString());
}
}

View file

@ -0,0 +1,31 @@
//
// DomainServerWebSessionData.h
// domain-server/src
//
// Created by Stephen Birarda on 2014-07-21.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_DomainServerWebSessionData_h
#define hifi_DomainServerWebSessionData_h
#include <QtCore/QObject>
#include <QtCore/QSet>
class DomainServerWebSessionData : public QObject {
Q_OBJECT
public:
DomainServerWebSessionData(const QJsonDocument& profileDocument);
const QString& getUsername() const { return _username; }
const QSet<QString>& getRoles() const { return _roles; }
private:
QString _username;
QSet<QString> _roles;
};
#endif // hifi_DomainServerWebSessionData_h