do not allow get user and task properties w\o auth

This commit is contained in:
Evgenii Alekseev 2017-11-26 15:30:59 +03:00
parent bb0a3c43be
commit 9dd63fc77e
26 changed files with 241 additions and 107 deletions

View File

@ -39,6 +39,7 @@ void QueuedEmailNotify::init(const QVariantHash &_settings)
void QueuedEmailNotify::setToken(const QString &_token) void QueuedEmailNotify::setToken(const QString &_token)
{ {
m_token = _token; m_token = _token;
m_helper->setToken(_token);
} }

View File

@ -102,6 +102,12 @@ QString QueuedEmailNotifyHelper::server() const
} }
QString QueuedEmailNotifyHelper::token() const
{
return m_token;
}
QString QueuedEmailNotifyHelper::username() const QString QueuedEmailNotifyHelper::username() const
{ {
return m_username; return m_username;
@ -156,6 +162,12 @@ void QueuedEmailNotifyHelper::setSslEnabled(const bool _sslEnabled)
} }
void QueuedEmailNotifyHelper::setToken(const QString &_token)
{
m_token = _token;
}
void QueuedEmailNotifyHelper::setUsername(const QString &_username) void QueuedEmailNotifyHelper::setUsername(const QString &_username)
{ {
qCDebug(LOG_PL) << "Set username" << _username; qCDebug(LOG_PL) << "Set username" << _username;
@ -215,14 +227,14 @@ QString QueuedEmailNotifyHelper::getEmail(const long long _id) const
{ {
qCDebug(LOG_PL) << "Get email for task ID" << _id; qCDebug(LOG_PL) << "Get email for task ID" << _id;
auto task = QueuedCoreAdaptor::getTask(_id, "user"); auto task = QueuedCoreAdaptor::getTask(_id, "user", token());
if (task.type() != Result::Content::Value) { if (task.type() != Result::Content::Value) {
qCWarning(LOG_LIB) << "Could not get task information" << _id; qCWarning(LOG_LIB) << "Could not get task information" << _id;
return ""; return "";
} }
auto userId = task.get().toLongLong(); auto userId = task.get().toLongLong();
auto user = QueuedCoreAdaptor::getUser(userId, "email"); auto user = QueuedCoreAdaptor::getUser(userId, "email", token());
if (user.type() != Result::Content::Value) { if (user.type() != Result::Content::Value) {
qCWarning(LOG_LIB) << "Could not get user information" << userId; qCWarning(LOG_LIB) << "Could not get user information" << userId;
return ""; return "";

View File

@ -29,6 +29,7 @@ class QueuedEmailNotifyHelper : public QObject
Q_PROPERTY(int port READ port WRITE setPort) Q_PROPERTY(int port READ port WRITE setPort)
Q_PROPERTY(QString server READ server WRITE setServer) Q_PROPERTY(QString server READ server WRITE setServer)
Q_PROPERTY(bool ssl READ isSslEnabled WRITE setSslEnabled) Q_PROPERTY(bool ssl READ isSslEnabled WRITE setSslEnabled)
Q_PROPERTY(QString token READ token WRITE setToken)
Q_PROPERTY(QString username READ username WRITE setUsername) Q_PROPERTY(QString username READ username WRITE setUsername)
public: public:
@ -50,6 +51,7 @@ public:
QString password() const; QString password() const;
int port() const; int port() const;
QString server() const; QString server() const;
QString token() const;
QString username() const; QString username() const;
void setFrom(const QString &_from); void setFrom(const QString &_from);
void setInsecureCurl(const bool _insecureCurl); void setInsecureCurl(const bool _insecureCurl);
@ -57,6 +59,7 @@ public:
void setPort(const int &_port); void setPort(const int &_port);
void setServer(const QString &_server); void setServer(const QString &_server);
void setSslEnabled(const bool _sslEnabled); void setSslEnabled(const bool _sslEnabled);
void setToken(const QString &_token);
void setUsername(const QString &_username); void setUsername(const QString &_username);
public slots: public slots:
@ -71,6 +74,7 @@ private:
int m_port = 0; int m_port = 0;
QString m_server; QString m_server;
bool m_ssl = false; bool m_ssl = false;
QString m_token;
QString m_username; QString m_username;
}; };

View File

@ -96,7 +96,7 @@ QVariantHash QueuedTcpServerResponseHelperApi1::getData(
case QueuedTcpServerResponseHelper::RequestPath::Task: case QueuedTcpServerResponseHelper::RequestPath::Task:
if (_type == "GET") if (_type == "GET")
output = QueuedTcpServerResponseHelperTask::getTask( output = QueuedTcpServerResponseHelperTask::getTask(
_arg.toLongLong(), _data); _arg.toLongLong(), _data, _token);
else if (_type == "POST") else if (_type == "POST")
output = QueuedTcpServerResponseHelperTask::addOrEditTask( output = QueuedTcpServerResponseHelperTask::addOrEditTask(
_arg.toLongLong(), _data, _token); _arg.toLongLong(), _data, _token);
@ -114,7 +114,8 @@ QVariantHash QueuedTcpServerResponseHelperApi1::getData(
break; break;
case QueuedTcpServerResponseHelper::RequestPath::User: case QueuedTcpServerResponseHelper::RequestPath::User:
if (_type == "GET") if (_type == "GET")
output = QueuedTcpServerResponseHelperUser::getUser(_arg, _data); output = QueuedTcpServerResponseHelperUser::getUser(_arg, _data,
_token);
else if (_type == "POST") else if (_type == "POST")
output = QueuedTcpServerResponseHelperUser::addOrEditUser( output = QueuedTcpServerResponseHelperUser::addOrEditUser(
_arg, _data, _token); _arg, _data, _token);

View File

@ -85,9 +85,8 @@ QueuedTcpServerResponseHelperTask::getDefinitions(const QVariantHash &_data)
} }
QVariantHash QVariantHash QueuedTcpServerResponseHelperTask::getTask(
QueuedTcpServerResponseHelperTask::getTask(const long long _id, const long long _id, const QVariantHash &_data, const QString &_token)
const QVariantHash &_data)
{ {
qCDebug(LOG_SERV) << "Get task" << _id << _data; qCDebug(LOG_SERV) << "Get task" << _id << _data;
@ -95,7 +94,7 @@ QueuedTcpServerResponseHelperTask::getTask(const long long _id,
QVariantHash output = {{"code", 200}}; QVariantHash output = {{"code", 200}};
if (property.isEmpty()) { if (property.isEmpty()) {
auto res = QueuedCoreAdaptor::getTask(_id); auto res = QueuedCoreAdaptor::getTask(_id, _token);
res.match( res.match(
[&output](const QVariantHash &val) { output["properties"] = val; }, [&output](const QVariantHash &val) { output["properties"] = val; },
[&output](const QueuedError &err) { [&output](const QueuedError &err) {
@ -152,7 +151,7 @@ QueuedTcpServerResponseHelperTask::startOrStopTask(const long long _id,
{ {
qCDebug(LOG_SERV) << "Change task state" << _id; qCDebug(LOG_SERV) << "Change task state" << _id;
auto res = QueuedCoreAdaptor::getTask(_id); auto res = QueuedCoreAdaptor::getTask(_id, _token);
QVariantHash output; QVariantHash output;
res.match( res.match(

View File

@ -28,7 +28,8 @@ QVariantHash addOrEditTask(const long long _id, const QVariantHash &_data,
const QString &_token); const QString &_token);
QueuedProcess::QueuedProcessDefinitions QueuedProcess::QueuedProcessDefinitions
getDefinitions(const QVariantHash &_data); getDefinitions(const QVariantHash &_data);
QVariantHash getTask(const long long _id, const QVariantHash &_data); QVariantHash getTask(const long long _id, const QVariantHash &_data,
const QString &_token);
QVariantHash getTasks(const QVariantHash &_data, const QString &_token); QVariantHash getTasks(const QVariantHash &_data, const QString &_token);
QVariantHash startOrStopTask(const long long _id, const QString &_token); QVariantHash startOrStopTask(const long long _id, const QString &_token);
QVariantHash startTask(const long long _id, const QString &_token); QVariantHash startTask(const long long _id, const QString &_token);

View File

@ -26,7 +26,7 @@ QVariantHash QueuedTcpServerResponseHelperUser::addOrEditUser(
qCDebug(LOG_SERV) << "Add user" << _user << "with data" << _data; qCDebug(LOG_SERV) << "Add user" << _user << "with data" << _data;
// try define if user exists first // try define if user exists first
auto userIdRes = QueuedCoreAdaptor::getUserId(_user); auto userIdRes = QueuedCoreAdaptor::getUserId(_user, _token);
long long userId = -1; long long userId = -1;
userIdRes.match([&userId](const long long val) { userId = val; }, userIdRes.match([&userId](const long long val) { userId = val; },
[&userId](const QueuedError &) {}); [&userId](const QueuedError &) {});
@ -116,13 +116,12 @@ QueuedTcpServerResponseHelperUser::getReport(const QVariantHash &_data,
} }
QVariantHash QVariantHash QueuedTcpServerResponseHelperUser::getUser(
QueuedTcpServerResponseHelperUser::getUser(const QString &_user, const QString &_user, const QVariantHash &_data, const QString &_token)
const QVariantHash &_data)
{ {
qCDebug(LOG_SERV) << "Get user data for" << _user << _data; qCDebug(LOG_SERV) << "Get user data for" << _user << _data;
auto userIdRes = QueuedCoreAdaptor::getUserId(_user); auto userIdRes = QueuedCoreAdaptor::getUserId(_user, _token);
long long userId = -1; long long userId = -1;
userIdRes.match([&userId](const long long val) { userId = val; }, userIdRes.match([&userId](const long long val) { userId = val; },
[](const QueuedError &) {}); [](const QueuedError &) {});
@ -133,7 +132,7 @@ QueuedTcpServerResponseHelperUser::getUser(const QString &_user,
QVariantHash output = {{"code", 200}}; QVariantHash output = {{"code", 200}};
if (property.isEmpty()) { if (property.isEmpty()) {
auto res = QueuedCoreAdaptor::getUser(userId); auto res = QueuedCoreAdaptor::getUser(userId, _token);
res.match( res.match(
[&output](const QVariantHash &val) { output["properties"] = val; }, [&output](const QVariantHash &val) { output["properties"] = val; },
[&output](const QueuedError &err) { [&output](const QueuedError &err) {

View File

@ -28,7 +28,8 @@ QVariantHash addOrEditUser(const QString &_user, const QVariantHash &_data,
const QString &_token); const QString &_token);
QueuedUser::QueuedUserDefinitions getDefinitions(const QVariantHash &_data); QueuedUser::QueuedUserDefinitions getDefinitions(const QVariantHash &_data);
QVariantHash getReport(const QVariantHash &_data, const QString &_token); QVariantHash getReport(const QVariantHash &_data, const QString &_token);
QVariantHash getUser(const QString &_user, const QVariantHash &_data); QVariantHash getUser(const QString &_user, const QVariantHash &_data,
const QString &_token);
QVariantHash getUsers(const QVariantHash &_data, const QString &_token); QVariantHash getUsers(const QVariantHash &_data, const QString &_token);
}; };

View File

@ -253,9 +253,11 @@ public:
* @brief get task by ID * @brief get task by ID
* @param _id * @param _id
* task ID * task ID
* @param _token
* user auth token
* @return task object or nullptr if no task found * @return task object or nullptr if no task found
*/ */
const QueuedProcess *task(const long long _id) const; const QueuedProcess *task(const long long _id, const QString &_token) const;
/** /**
* list of tasks which match criteria * list of tasks which match criteria
* @param _user * @param _user
@ -276,16 +278,20 @@ public:
* @brief get user by ID * @brief get user by ID
* @param _id * @param _id
* user ID * user ID
* @param _token
* user auth token
* @return user object or nullptr if no user found * @return user object or nullptr if no user found
*/ */
const QueuedUser *user(const long long _id) const; const QueuedUser *user(const long long _id, const QString &_token) const;
/** /**
* @brief get user by name * @brief get user by name
* @param _name * @param _name
* user name * user name
* @param _token
* user auth token
* @return user object or nullptr if no user found * @return user object or nullptr if no user found
*/ */
const QueuedUser *user(const QString &_name) const; const QueuedUser *user(const QString &_name, const QString &_token) const;
/** /**
* list of users which match criteria * list of users which match criteria
* @param _lastLogged * @param _lastLogged

View File

@ -232,18 +232,23 @@ QueuedResult<QueuedStatusMap> getStatus();
* @brief get all task properties * @brief get all task properties
* @param _id * @param _id
* task ID * task ID
* @param _token
* user auth token
* @return task properties * @return task properties
*/ */
QueuedResult<QVariantHash> getTask(const long long _id); QueuedResult<QVariantHash> getTask(const long long _id, const QString &_token);
/** /**
* @brief get task property * @brief get task property
* @param _id * @param _id
* task id * task id
* @param _property * @param _property
* task property name * task property name
* @param _token
* user auth token
* @return task property value * @return task property value
*/ */
QueuedResult<QVariant> getTask(const long long _id, const QString &_property); QueuedResult<QVariant> getTask(const long long _id, const QString &_property,
const QString &_token);
/** /**
* @brief get tasks list * @brief get tasks list
* @param _user * @param _user
@ -264,26 +269,33 @@ QueuedResult<QList<QVariantHash>> getTasks(const long long _user,
* @brief get user properties * @brief get user properties
* @param _id * @param _id
* user id * user id
* @param _token
* user auth token
* @return user properties * @return user properties
*/ */
QueuedResult<QVariantHash> getUser(const long long _id); QueuedResult<QVariantHash> getUser(const long long _id, const QString &_token);
/** /**
* @brief get user property * @brief get user property
* @param _id * @param _id
* user id * user id
* @param _property * @param _property
* user property name * user property name
* @param _token
* user auth token
* @return user property value * @return user property value
*/ */
QueuedResult<QVariant> getUser(const long long _id, const QString &_property); QueuedResult<QVariant> getUser(const long long _id, const QString &_property,
const QString &_token);
/** /**
* @brief get user ID * @brief get user ID
* @param _name * @param _name
* user name * user name
* @param _token
* user auth token
* @return user ID or {0, -1} if no user found. If _name is numeric value it * @return user ID or {0, -1} if no user found. If _name is numeric value it
* returns converted one * returns converted one
*/ */
QueuedResult<long long> getUserId(const QString &_name); QueuedResult<long long> getUserId(const QString &_name, const QString &_token);
/** /**
* @brief get users list * @brief get users list
* @param _lastLogged * @param _lastLogged

View File

@ -68,27 +68,35 @@ public slots:
* task ID * task ID
* @param property * @param property
* property name * property name
* @param token
* user auth token
* @remark if property is empty it return map of all properties * @remark if property is empty it return map of all properties
* @return property value or empty if task or property not found * @return property value or empty if task or property not found
*/ */
QDBusVariant Task(const long long id, const QString &property); QDBusVariant Task(const long long id, const QString &property,
const QString &token);
/** /**
* @brief get user property * @brief get user property
* @param id * @param id
* user ID * user ID
* @param property * @param property
* property name * property name
* @param token
* user auth token
* @remark if property is empty it return map of all properties * @remark if property is empty it return map of all properties
* @return property value or empty if user or property not found * @return property value or empty if user or property not found
*/ */
QDBusVariant User(const long long id, const QString &property); QDBusVariant User(const long long id, const QString &property,
const QString &token);
/** /**
* @brief get user ID by name * @brief get user ID by name
* @param name * @param name
* user name * user name
* @param token
* user auth token
* @return user ID or -1 if no user found * @return user ID or -1 if no user found
*/ */
QDBusVariant UserIdByName(const QString &name); QDBusVariant UserIdByName(const QString &name, const QString &token);
private: private:
/** /**

View File

@ -47,8 +47,11 @@ public:
* pointer to parent item * pointer to parent item
* @param _database * @param _database
* pointer to database object * pointer to database object
* @param _token
* user auth token
*/ */
explicit QueuedReportManager(QObject *_parent, QueuedDatabase *_database); explicit QueuedReportManager(QObject *_parent, QueuedDatabase *_database,
const QString &_token);
/** /**
* @brief QueuedReportManager class destructor * @brief QueuedReportManager class destructor
*/ */
@ -96,6 +99,10 @@ private:
* @brief pointer to database object * @brief pointer to database object
*/ */
QueuedDatabase *m_database = nullptr; QueuedDatabase *m_database = nullptr;
/**
* @brief object token
*/
QString m_token;
}; };

View File

@ -262,9 +262,11 @@ public:
* @brief get task by ID * @brief get task by ID
* @param _id * @param _id
* task ID * task ID
* @param _token
* user auth token
* @return task object or nullptr if no task found * @return task object or nullptr if no task found
*/ */
const QueuedProcess *task(const long long _id) const; const QueuedProcess *task(const long long _id, const QString &_token) const;
/** /**
* list of tasks which match criteria * list of tasks which match criteria
* @param _user * @param _user
@ -285,16 +287,20 @@ public:
* @brief get user by ID * @brief get user by ID
* @param _id * @param _id
* user ID * user ID
* @param _token
* user auth token
* @return user object or nullptr if no user found * @return user object or nullptr if no user found
*/ */
const QueuedUser *user(const long long _id) const; const QueuedUser *user(const long long _id, const QString &_token) const;
/** /**
* @brief get user by name * @brief get user by name
* @param _name * @param _name
* user name * user name
* @param _token
* user auth token
* @return user object or nullptr if no user found * @return user object or nullptr if no user found
*/ */
const QueuedUser *user(const QString &_name) const; const QueuedUser *user(const QString &_name, const QString &_token) const;
/** /**
* list of users which match criteria * list of users which match criteria
* @param _lastLogged * @param _lastLogged
@ -356,6 +362,10 @@ private slots:
void updateUserLoginTime(const long long _id, const QDateTime &_time); void updateUserLoginTime(const long long _id, const QDateTime &_time);
private: private:
/**
* @brief admin token for internal services
*/
QString m_adminToken;
/** /**
* @brief private helper pointer * @brief private helper pointer
*/ */
@ -406,6 +416,10 @@ private:
* @brief init processes * @brief init processes
*/ */
void initProcesses(); void initProcesses();
/**
* @brief init reports
*/
void initReports();
/** /**
* @brief init settings and database * @brief init settings and database
* @param _configuration * @param _configuration

View File

@ -258,11 +258,12 @@ QueuedResult<bool> QueuedCore::stopTask(const long long _id,
/** /**
* @fn task * @fn task
*/ */
const QueuedProcess *QueuedCore::task(const long long _id) const const QueuedProcess *QueuedCore::task(const long long _id,
const QString &_token) const
{ {
qCDebug(LOG_LIB) << "Get task by ID" << _id; qCDebug(LOG_LIB) << "Get task by ID" << _id;
return m_impl->task(_id); return m_impl->task(_id, _token);
} }
@ -282,22 +283,24 @@ QueuedCore::taskReport(const long long _user, const QDateTime &_from,
/** /**
* @fn user * @fn user
*/ */
const QueuedUser *QueuedCore::user(const long long _id) const const QueuedUser *QueuedCore::user(const long long _id,
const QString &_token) const
{ {
qCDebug(LOG_LIB) << "Get user by ID" << _id; qCDebug(LOG_LIB) << "Get user by ID" << _id;
return m_impl->user(_id); return m_impl->user(_id, _token);
} }
/** /**
* @fn user * @fn user
*/ */
const QueuedUser *QueuedCore::user(const QString &_name) const const QueuedUser *QueuedCore::user(const QString &_name,
const QString &_token) const
{ {
qCDebug(LOG_LIB) << "Get user by name" << _name; qCDebug(LOG_LIB) << "Get user by name" << _name;
return m_impl->user(_name); return m_impl->user(_name, _token);
} }

View File

@ -346,11 +346,12 @@ QueuedResult<QueuedStatusMap> QueuedCoreAdaptor::getStatus()
/** /**
* @fn getTask * @fn getTask
*/ */
QueuedResult<QVariantHash> QueuedCoreAdaptor::getTask(const long long _id) QueuedResult<QVariantHash> QueuedCoreAdaptor::getTask(const long long _id,
const QString &_token)
{ {
qCDebug(LOG_DBUS) << "Get task properties" << _id; qCDebug(LOG_DBUS) << "Get task properties" << _id;
auto res = getTask(_id, ""); auto res = getTask(_id, "", _token);
QueuedResult<QVariantHash> output; QueuedResult<QVariantHash> output;
res.match( res.match(
@ -367,11 +368,12 @@ QueuedResult<QVariantHash> QueuedCoreAdaptor::getTask(const long long _id)
* @fn getTask * @fn getTask
*/ */
QueuedResult<QVariant> QueuedCoreAdaptor::getTask(const long long _id, QueuedResult<QVariant> QueuedCoreAdaptor::getTask(const long long _id,
const QString &_property) const QString &_property,
const QString &_token)
{ {
qCDebug(LOG_DBUS) << "Get task property" << _id << _property; qCDebug(LOG_DBUS) << "Get task property" << _id << _property;
QVariantList args = {_id, _property}; QVariantList args = {_id, _property, _token};
return sendRequest<QVariant>(QueuedConfig::DBUS_SERVICE, return sendRequest<QVariant>(QueuedConfig::DBUS_SERVICE,
QueuedConfig::DBUS_PROPERTY_PATH, QueuedConfig::DBUS_PROPERTY_PATH,
QueuedConfig::DBUS_SERVICE, "Task", args); QueuedConfig::DBUS_SERVICE, "Task", args);
@ -398,11 +400,12 @@ QueuedCoreAdaptor::getTasks(const long long _user, const QDateTime &_from,
/** /**
* @fn getUser * @fn getUser
*/ */
QueuedResult<QVariantHash> QueuedCoreAdaptor::getUser(const long long _id) QueuedResult<QVariantHash> QueuedCoreAdaptor::getUser(const long long _id,
const QString &_token)
{ {
qCDebug(LOG_DBUS) << "Get user property" << _id; qCDebug(LOG_DBUS) << "Get user property" << _id;
auto res = getUser(_id, ""); auto res = getUser(_id, "", _token);
QueuedResult<QVariantHash> output; QueuedResult<QVariantHash> output;
res.match( res.match(
@ -419,11 +422,12 @@ QueuedResult<QVariantHash> QueuedCoreAdaptor::getUser(const long long _id)
* @fn getUser * @fn getUser
*/ */
QueuedResult<QVariant> QueuedCoreAdaptor::getUser(const long long _id, QueuedResult<QVariant> QueuedCoreAdaptor::getUser(const long long _id,
const QString &_property) const QString &_property,
const QString &_token)
{ {
qCDebug(LOG_DBUS) << "Get user property" << _id << _property; qCDebug(LOG_DBUS) << "Get user property" << _id << _property;
QVariantList args = {_id, _property}; QVariantList args = {_id, _property, _token};
return sendRequest<QVariant>(QueuedConfig::DBUS_SERVICE, return sendRequest<QVariant>(QueuedConfig::DBUS_SERVICE,
QueuedConfig::DBUS_PROPERTY_PATH, QueuedConfig::DBUS_PROPERTY_PATH,
QueuedConfig::DBUS_SERVICE, "User", args); QueuedConfig::DBUS_SERVICE, "User", args);
@ -433,7 +437,8 @@ QueuedResult<QVariant> QueuedCoreAdaptor::getUser(const long long _id,
/** /**
* @fn getUserId * @fn getUserId
*/ */
QueuedResult<long long> QueuedCoreAdaptor::getUserId(const QString &_name) QueuedResult<long long> QueuedCoreAdaptor::getUserId(const QString &_name,
const QString &_token)
{ {
qCDebug(LOG_DBUS) << "Get user ID for" << _name; qCDebug(LOG_DBUS) << "Get user ID for" << _name;
@ -442,7 +447,7 @@ QueuedResult<long long> QueuedCoreAdaptor::getUserId(const QString &_name)
if (status) if (status)
return stringToLong; return stringToLong;
QVariantList args = {_name}; QVariantList args = {_name, _token};
return sendRequest<long long>( return sendRequest<long long>(
QueuedConfig::DBUS_SERVICE, QueuedConfig::DBUS_PROPERTY_PATH, QueuedConfig::DBUS_SERVICE, QueuedConfig::DBUS_PROPERTY_PATH,
QueuedConfig::DBUS_SERVICE, "UserIdByName", args); QueuedConfig::DBUS_SERVICE, "UserIdByName", args);

View File

@ -151,7 +151,7 @@ QDBusVariant QueuedCoreInterface::TaskEdit(
<< nice << uid << gid << cpu << gpu << memory << gpumemory << nice << uid << gid << cpu << gpu << memory << gpumemory
<< storage; << storage;
auto task = m_core->task(id); auto task = m_core->task(id, token);
if (!task) { if (!task) {
qCWarning(LOG_DBUS) << "Could not find task" << id; qCWarning(LOG_DBUS) << "Could not find task" << id;
return QueuedCoreAdaptor::toDBusVariant(QueuedResult<bool>( return QueuedCoreAdaptor::toDBusVariant(QueuedResult<bool>(
@ -258,7 +258,7 @@ QueuedCoreInterface::UserEdit(const qlonglong id, const QString &name,
<< memory << gpumemory << storage; << memory << gpumemory << storage;
// get user object first to match limits // get user object first to match limits
auto user = m_core->user(id); auto user = m_core->user(id, token);
if (!user) { if (!user) {
qCWarning(LOG_DBUS) << "Could not find user" << id; qCWarning(LOG_DBUS) << "Could not find user" << id;
return QueuedCoreAdaptor::toDBusVariant(QueuedResult<bool>( return QueuedCoreAdaptor::toDBusVariant(QueuedResult<bool>(

View File

@ -24,7 +24,7 @@
#include <queued/Queued.h> #include <queued/Queued.h>
#include <queued/private/QueuedCorePrivate.h> #include <queued/private/QueuedCorePrivate.h>
#include "queued/QueuedDatabaseSchema.h" #include <queued/QueuedDatabaseSchema.h>
#include <queued/private/QueuedCorePrivateHelper.h> #include <queued/private/QueuedCorePrivateHelper.h>
@ -117,7 +117,7 @@ QueuedResult<long long> QueuedCorePrivate::addUser(
} }
// check if already exists // check if already exists
auto userObj = user(_name); auto userObj = user(_name, _token);
if (userObj) { if (userObj) {
qCWarning(LOG_LIB) << "User" << _name << "already exists"; qCWarning(LOG_LIB) << "User" << _name << "already exists";
return QueuedError("User already exists", return QueuedError("User already exists",
@ -261,7 +261,7 @@ QueuedResult<bool> QueuedCorePrivate::editUser(const long long _id,
{ {
qCDebug(LOG_LIB) << "Edit user with ID" << _id; qCDebug(LOG_LIB) << "Edit user with ID" << _id;
auto userObj = user(_id); auto userObj = user(_id, _token);
if (!userObj) { if (!userObj) {
qCWarning(LOG_LIB) << "Could not find user with ID" << _id; qCWarning(LOG_LIB) << "Could not find user with ID" << _id;
return QueuedError("User does not exist", return QueuedError("User does not exist",
@ -508,11 +508,34 @@ QueuedResult<bool> QueuedCorePrivate::stopTask(const long long _id,
/** /**
* @fn task * @fn task
*/ */
const QueuedProcess *QueuedCorePrivate::task(const long long _id) const const QueuedProcess *QueuedCorePrivate::task(const long long _id,
const QString &_token) const
{ {
qCDebug(LOG_LIB) << "Get task by ID" << _id; qCDebug(LOG_LIB) << "Get task by ID" << _id;
return m_processes->process(_id); auto task = m_processes->process(_id);
if (!task) {
qCWarning(LOG_LIB) << "Could not find task with ID" << _id;
return task;
}
// check permissions
auto authUser = m_users->user(_token, true);
if (!authUser) {
qCWarning(LOG_LIB) << "Could not find auth user" << _token;
return nullptr;
}
long long userAuthId = authUser->index();
bool isAdmin = m_users->authorize(_token, QueuedEnums::Permission::Admin);
if (isAdmin) {
return task;
} else if (userAuthId == task->user()) {
return task;
} else {
qCInfo(LOG_LIB) << "User" << _token << "not allowed to get task" << _id;
return nullptr;
}
} }
@ -554,22 +577,48 @@ QueuedCorePrivate::taskReport(const long long _user, const QDateTime &_from,
/** /**
* @fn user * @fn user
*/ */
const QueuedUser *QueuedCorePrivate::user(const long long _id) const const QueuedUser *QueuedCorePrivate::user(const long long _id,
const QString &_token) const
{ {
qCDebug(LOG_LIB) << "Get user by ID" << _id; qCDebug(LOG_LIB) << "Get user by ID" << _id;
return m_users->user(_id); auto user = m_users->user(_id);
if (!user) {
qCWarning(LOG_LIB) << "Could not find user with ID" << _id;
return user;
}
// check permissions
auto authUser = m_users->user(_token, true);
if (!authUser) {
qCWarning(LOG_LIB) << "Could not find auth user" << _token;
return nullptr;
}
long long userAuthId = authUser->index();
bool isAdmin = m_users->authorize(_token, QueuedEnums::Permission::Admin);
if (isAdmin) {
return user;
} else if (userAuthId == user->index()) {
return user;
} else {
qCInfo(LOG_LIB) << "User" << _token << "not allowed to get user" << _id;
return nullptr;
}
} }
/** /**
* @fn user * @fn user
*/ */
const QueuedUser *QueuedCorePrivate::user(const QString &_name) const const QueuedUser *QueuedCorePrivate::user(const QString &_name,
const QString &_token) const
{ {
qCDebug(LOG_LIB) << "Get user by name" << _name; qCDebug(LOG_LIB) << "Get user by name" << _name;
return m_users->user(_name, false); auto userObj = m_users->user(_name, false);
return userObj ? user(userObj->index(), _token) : nullptr;
} }

View File

@ -26,6 +26,7 @@
#include "queued/QueuedDatabaseSchema.h" #include "queued/QueuedDatabaseSchema.h"
#include <queued/QueuedStaticConfig.h>
#include <queued/private/QueuedCorePrivate.h> #include <queued/private/QueuedCorePrivate.h>
@ -132,7 +133,7 @@ QueuedResult<long long> QueuedCorePrivateHelper::addTaskPrivate(
// add to database // add to database
auto ids = users()->ids(_userId); auto ids = users()->ids(_userId);
auto userObj = m_core->user(_userId); auto userObj = m_core->user(_userId, m_core->m_adminToken);
if (!userObj) { if (!userObj) {
qCWarning(LOG_LIB) << "Could not find task user" << _userId; qCWarning(LOG_LIB) << "Could not find task user" << _userId;
return QueuedError("Invalid token", return QueuedError("Invalid token",

View File

@ -80,8 +80,12 @@ void QueuedCorePrivate::init(const QString &_configuration)
// init parts // init parts
initSettings(_configuration); initSettings(_configuration);
initUsers(); initUsers();
// create admin token
m_adminToken = m_users->authorize(m_settings->admin().name);
initPlugins(); initPlugins();
initProcesses(); initProcesses();
initReports();
// settings update notifier // settings update notifier
m_connections m_connections
@ -106,9 +110,8 @@ void QueuedCorePrivate::initPlugins()
= m_advancedSettings->get(QueuedConfig::QueuedSettings::Plugins) = m_advancedSettings->get(QueuedConfig::QueuedSettings::Plugins)
.toString() .toString()
.split('\n'); .split('\n');
QString token = m_users->authorize(m_settings->admin().name);
m_plugins = m_helper->initObject(m_plugins, token); m_plugins = m_helper->initObject(m_plugins, m_adminToken);
for (auto &plugin : pluginList) for (auto &plugin : pluginList)
m_plugins->loadPlugin(plugin, pluginSettings(plugin)); m_plugins->loadPlugin(plugin, pluginSettings(plugin));
} }
@ -143,6 +146,16 @@ void QueuedCorePrivate::initProcesses()
} }
/**
* @fn initReports
*/
void QueuedCorePrivate::initReports()
{
// report manager
m_reports = m_helper->initObject(m_reports, m_database, m_adminToken);
}
/** /**
* @fn initSettings * @fn initSettings
*/ */
@ -179,8 +192,6 @@ void QueuedCorePrivate::initSettings(const QString &_configuration)
QueuedConfig::DATABASE_VERSION); QueuedConfig::DATABASE_VERSION);
} }
// report manager
m_reports = m_helper->initObject(m_reports, m_database);
// database manager // database manager
m_databaseManager = m_helper->initObject(m_databaseManager, m_database); m_databaseManager = m_helper->initObject(m_databaseManager, m_database);
} }

View File

@ -69,11 +69,12 @@ QDBusVariant QueuedPropertyInterface::Option(const QString &property,
* @fn Task * @fn Task
*/ */
QDBusVariant QueuedPropertyInterface::Task(const long long id, QDBusVariant QueuedPropertyInterface::Task(const long long id,
const QString &property) const QString &property,
const QString &token)
{ {
qCDebug(LOG_DBUS) << "Get property" << property << "from task" << id; qCDebug(LOG_DBUS) << "Get property" << property << "from task" << id;
auto task = m_core->task(id); auto task = m_core->task(id, token);
if (!task) { if (!task) {
qCWarning(LOG_DBUS) << "Could not find task" << id; qCWarning(LOG_DBUS) << "Could not find task" << id;
return QueuedCoreAdaptor::toDBusVariant(QueuedResult<QVariant>( return QueuedCoreAdaptor::toDBusVariant(QueuedResult<QVariant>(
@ -99,11 +100,12 @@ QDBusVariant QueuedPropertyInterface::Task(const long long id,
* @fn User * @fn User
*/ */
QDBusVariant QueuedPropertyInterface::User(const long long id, QDBusVariant QueuedPropertyInterface::User(const long long id,
const QString &property) const QString &property,
const QString &token)
{ {
qCDebug(LOG_DBUS) << "Get property" << property << "from user" << id; qCDebug(LOG_DBUS) << "Get property" << property << "from user" << id;
auto user = m_core->user(id); auto user = m_core->user(id, token);
if (!user) { if (!user) {
qCWarning(LOG_DBUS) << "Could not find user" << id; qCWarning(LOG_DBUS) << "Could not find user" << id;
return QueuedCoreAdaptor::toDBusVariant(QueuedResult<QVariant>( return QueuedCoreAdaptor::toDBusVariant(QueuedResult<QVariant>(
@ -128,11 +130,12 @@ QDBusVariant QueuedPropertyInterface::User(const long long id,
/** /**
* @fn UserIdByName * @fn UserIdByName
*/ */
QDBusVariant QueuedPropertyInterface::UserIdByName(const QString &name) QDBusVariant QueuedPropertyInterface::UserIdByName(const QString &name,
const QString &token)
{ {
qCDebug(LOG_DBUS) << "Look for user ID" << name; qCDebug(LOG_DBUS) << "Look for user ID" << name;
auto user = m_core->user(name); auto user = m_core->user(name, token);
if (!user) { if (!user) {
qCWarning(LOG_DBUS) << "Could not find user" << name; qCWarning(LOG_DBUS) << "Could not find user" << name;
return QueuedCoreAdaptor::toDBusVariant(QueuedResult<long long>( return QueuedCoreAdaptor::toDBusVariant(QueuedResult<long long>(

View File

@ -33,9 +33,11 @@
* @fn QueuedReportManager * @fn QueuedReportManager
*/ */
QueuedReportManager::QueuedReportManager(QObject *_parent, QueuedReportManager::QueuedReportManager(QObject *_parent,
QueuedDatabase *_database) QueuedDatabase *_database,
const QString &_token)
: QObject(_parent) : QObject(_parent)
, m_database(_database) , m_database(_database)
, m_token(_token)
{ {
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
} }
@ -98,7 +100,7 @@ QList<QVariantHash> QueuedReportManager::performance(const QueuedCore *_core,
// append // append
long long userId = task.value("user").toLongLong(); long long userId = task.value("user").toLongLong();
auto userObj = _core->user(userId); auto userObj = _core->user(userId, m_token);
QVariantHash currentData = hashOutput[userId]; QVariantHash currentData = hashOutput[userId];
currentData["cpu"] currentData["cpu"]
= currentData.value("cpu", 0).toLongLong() + limits.cpu; = currentData.value("cpu", 0).toLongLong() + limits.cpu;

View File

@ -219,23 +219,25 @@ QueuedctlCommon::process(QCommandLineParser &_parser, const QString &_cache,
: QueuedctlArgument::Invalid; : QueuedctlArgument::Invalid;
checkArgs(args, QueuedctlArguments[command].positionalArgsCount, _parser); checkArgs(args, QueuedctlArguments[command].positionalArgsCount, _parser);
QString token = (id == QueuedctlArgument::Auth)
? ""
: QueuedctlAuth::getToken(_cache, _user);
switch (id) { switch (id) {
case QueuedctlArgument::Auth: { case QueuedctlArgument::Auth: {
result = QueuedctlAuth::auth(_user, _cache); result = QueuedctlAuth::auth(_user, _cache);
break; break;
} }
case QueuedctlArgument::OptionGet: { case QueuedctlArgument::OptionGet: {
QString token = QueuedctlAuth::getToken(_cache, _user);
result = QueuedctlOption::getOption(args.at(1), token); result = QueuedctlOption::getOption(args.at(1), token);
break; break;
} }
case QueuedctlArgument::OptionSet: { case QueuedctlArgument::OptionSet: {
QString token = QueuedctlAuth::getToken(_cache, _user);
result = QueuedctlOption::editOption(args.at(1), args.at(2), token); result = QueuedctlOption::editOption(args.at(1), args.at(2), token);
break; break;
} }
case QueuedctlArgument::PermissionAdd: { case QueuedctlArgument::PermissionAdd: {
auto userIdRes = QueuedCoreAdaptor::getUserId(args.at(1)); auto userIdRes = QueuedCoreAdaptor::getUserId(args.at(1), token);
long long userId = -1; long long userId = -1;
userIdRes.match([&userId](const long long val) { userId = val; }, userIdRes.match([&userId](const long long val) { userId = val; },
[&result](const QueuedError &err) { [&result](const QueuedError &err) {
@ -243,12 +245,11 @@ QueuedctlCommon::process(QCommandLineParser &_parser, const QString &_cache,
}); });
if (userId == -1) if (userId == -1)
break; break;
QString token = QueuedctlAuth::getToken(_cache, _user);
result = QueuedctlPermissions::addPermission(userId, args.at(2), token); result = QueuedctlPermissions::addPermission(userId, args.at(2), token);
break; break;
} }
case QueuedctlArgument::PermissionRemove: { case QueuedctlArgument::PermissionRemove: {
auto userIdRes = QueuedCoreAdaptor::getUserId(args.at(1)); auto userIdRes = QueuedCoreAdaptor::getUserId(args.at(1), token);
long long userId = -1; long long userId = -1;
userIdRes.match([&userId](const long long val) { userId = val; }, userIdRes.match([&userId](const long long val) { userId = val; },
[&result](const QueuedError &err) { [&result](const QueuedError &err) {
@ -256,13 +257,11 @@ QueuedctlCommon::process(QCommandLineParser &_parser, const QString &_cache,
}); });
if (userId == -1) if (userId == -1)
break; break;
QString token = QueuedctlAuth::getToken(_cache, _user);
result result
= QueuedctlPermissions::removePermission(userId, args.at(2), token); = QueuedctlPermissions::removePermission(userId, args.at(2), token);
break; break;
} }
case QueuedctlArgument::PluginAdd: { case QueuedctlArgument::PluginAdd: {
QString token = QueuedctlAuth::getToken(_cache, _user);
result = QueuedctlPlugins::addPlugin(args.at(1), token); result = QueuedctlPlugins::addPlugin(args.at(1), token);
break; break;
} }
@ -271,12 +270,10 @@ QueuedctlCommon::process(QCommandLineParser &_parser, const QString &_cache,
break; break;
} }
case QueuedctlArgument::PluginRemove: { case QueuedctlArgument::PluginRemove: {
QString token = QueuedctlAuth::getToken(_cache, _user);
result = QueuedctlPlugins::removePlugin(args.at(1), token); result = QueuedctlPlugins::removePlugin(args.at(1), token);
break; break;
} }
case QueuedctlArgument::Report: { case QueuedctlArgument::Report: {
QString token = QueuedctlAuth::getToken(_cache, _user);
result = QueuedctlUser::getReport(_parser, token); result = QueuedctlUser::getReport(_parser, token);
break; break;
} }
@ -293,45 +290,40 @@ QueuedctlCommon::process(QCommandLineParser &_parser, const QString &_cache,
break; break;
} }
case QueuedctlArgument::TaskAdd: { case QueuedctlArgument::TaskAdd: {
QString token = QueuedctlAuth::getToken(_cache, _user); auto definitions = QueuedctlTask::getDefinitions(_parser, false, token);
auto definitions = QueuedctlTask::getDefinitions(_parser, false);
result = QueuedctlTask::addTask(definitions, token); result = QueuedctlTask::addTask(definitions, token);
break; break;
} }
case QueuedctlArgument::TaskGet: { case QueuedctlArgument::TaskGet: {
result = QueuedctlTask::getTask(args.at(1).toLongLong(), args.at(2)); result = QueuedctlTask::getTask(args.at(1).toLongLong(), args.at(2),
token);
break; break;
} }
case QueuedctlArgument::TaskList: { case QueuedctlArgument::TaskList: {
QString token = QueuedctlAuth::getToken(_cache, _user);
result = QueuedctlTask::getTasks(_parser, token); result = QueuedctlTask::getTasks(_parser, token);
break; break;
} }
case QueuedctlArgument::TaskSet: { case QueuedctlArgument::TaskSet: {
QString token = QueuedctlAuth::getToken(_cache, _user); auto definitions = QueuedctlTask::getDefinitions(_parser, true, token);
auto definitions = QueuedctlTask::getDefinitions(_parser, true);
result = QueuedctlTask::setTask(args.at(1).toLongLong(), definitions, result = QueuedctlTask::setTask(args.at(1).toLongLong(), definitions,
token); token);
break; break;
} }
case QueuedctlArgument::TaskStart: { case QueuedctlArgument::TaskStart: {
QString token = QueuedctlAuth::getToken(_cache, _user);
result = QueuedctlTask::startTask(args.at(1).toLongLong(), token); result = QueuedctlTask::startTask(args.at(1).toLongLong(), token);
break; break;
} }
case QueuedctlArgument::TaskStop: { case QueuedctlArgument::TaskStop: {
QString token = QueuedctlAuth::getToken(_cache, _user);
result = QueuedctlTask::stopTask(args.at(1).toLongLong(), token); result = QueuedctlTask::stopTask(args.at(1).toLongLong(), token);
break; break;
} }
case QueuedctlArgument::UserAdd: { case QueuedctlArgument::UserAdd: {
QString token = QueuedctlAuth::getToken(_cache, _user);
auto definitions = QueuedctlUser::getDefinitions(_parser, false); auto definitions = QueuedctlUser::getDefinitions(_parser, false);
result = QueuedctlUser::addUser(definitions, token); result = QueuedctlUser::addUser(definitions, token);
break; break;
} }
case QueuedctlArgument::UserGet: { case QueuedctlArgument::UserGet: {
auto userIdRes = QueuedCoreAdaptor::getUserId(args.at(1)); auto userIdRes = QueuedCoreAdaptor::getUserId(args.at(1), token);
long long userId = -1; long long userId = -1;
userIdRes.match([&userId](const long long val) { userId = val; }, userIdRes.match([&userId](const long long val) { userId = val; },
[&result](const QueuedError &err) { [&result](const QueuedError &err) {
@ -339,16 +331,15 @@ QueuedctlCommon::process(QCommandLineParser &_parser, const QString &_cache,
}); });
if (userId == -1) if (userId == -1)
break; break;
result = QueuedctlUser::getUser(userId, args.at(2)); result = QueuedctlUser::getUser(userId, args.at(2), token);
break; break;
} }
case QueuedctlArgument::UserList: { case QueuedctlArgument::UserList: {
QString token = QueuedctlAuth::getToken(_cache, _user);
result = QueuedctlUser::getUsers(_parser, token); result = QueuedctlUser::getUsers(_parser, token);
break; break;
} }
case QueuedctlArgument::UserSet: { case QueuedctlArgument::UserSet: {
auto userIdRes = QueuedCoreAdaptor::getUserId(args.at(1)); auto userIdRes = QueuedCoreAdaptor::getUserId(args.at(1), token);
long long userId = -1; long long userId = -1;
userIdRes.match([&userId](const long long val) { userId = val; }, userIdRes.match([&userId](const long long val) { userId = val; },
[&result](const QueuedError &err) { [&result](const QueuedError &err) {
@ -356,7 +347,6 @@ QueuedctlCommon::process(QCommandLineParser &_parser, const QString &_cache,
}); });
if (userId == -1) if (userId == -1)
break; break;
QString token = QueuedctlAuth::getToken(_cache, _user);
auto definitions = QueuedctlUser::getDefinitions(_parser, true); auto definitions = QueuedctlUser::getDefinitions(_parser, true);
result = QueuedctlUser::setUser(userId, definitions, token); result = QueuedctlUser::setUser(userId, definitions, token);
break; break;

View File

@ -50,7 +50,7 @@ QueuedctlCommon::QueuedctlResult QueuedctlTask::addTask(
QueuedProcess::QueuedProcessDefinitions QueuedProcess::QueuedProcessDefinitions
QueuedctlTask::getDefinitions(const QCommandLineParser &_parser, QueuedctlTask::getDefinitions(const QCommandLineParser &_parser,
const bool _expandAll) const bool _expandAll, const QString &_token)
{ {
qCDebug(LOG_APP) << "Parse task definitions from parser, expand all" qCDebug(LOG_APP) << "Parse task definitions from parser, expand all"
<< _expandAll; << _expandAll;
@ -68,7 +68,8 @@ QueuedctlTask::getDefinitions(const QCommandLineParser &_parser,
if (_parser.value("task-user").isEmpty()) { if (_parser.value("task-user").isEmpty()) {
definitions.user = 0; definitions.user = 0;
} else { } else {
auto res = QueuedCoreAdaptor::getUserId(_parser.value("task-user")); auto res
= QueuedCoreAdaptor::getUserId(_parser.value("task-user"), _token);
res.match( res.match(
[&definitions](const long long val) { definitions.user = val; }, [&definitions](const long long val) { definitions.user = val; },
[&definitions](const QueuedError &) { definitions.user = 0; }); [&definitions](const QueuedError &) { definitions.user = 0; });
@ -105,14 +106,15 @@ QueuedctlTask::getDefinitions(const QCommandLineParser &_parser,
QueuedctlCommon::QueuedctlResult QueuedctlCommon::QueuedctlResult
QueuedctlTask::getTask(const long long _id, const QString &_property) QueuedctlTask::getTask(const long long _id, const QString &_property,
const QString &_token)
{ {
qCDebug(LOG_APP) << "Get property" << _property << "from task" << _id; qCDebug(LOG_APP) << "Get property" << _property << "from task" << _id;
QueuedctlCommon::QueuedctlResult output; QueuedctlCommon::QueuedctlResult output;
if (_property.isEmpty()) { if (_property.isEmpty()) {
auto res = QueuedCoreAdaptor::getTask(_id); auto res = QueuedCoreAdaptor::getTask(_id, _token);
res.match( res.match(
[&output](const QVariantHash &val) { [&output](const QVariantHash &val) {
output.status = true; output.status = true;
@ -143,7 +145,8 @@ QueuedctlTask::getTasks(const QCommandLineParser &_parser,
{ {
long long userId = -1; long long userId = -1;
if (!_parser.value("task-user").isEmpty()) { if (!_parser.value("task-user").isEmpty()) {
auto res = QueuedCoreAdaptor::getUserId(_parser.value("task-user")); auto res
= QueuedCoreAdaptor::getUserId(_parser.value("task-user"), _token);
res.match([&userId](const long long val) { userId = val; }, res.match([&userId](const long long val) { userId = val; },
[&userId](const QueuedError &) {}); [&userId](const QueuedError &) {});
} }

View File

@ -30,9 +30,10 @@ QueuedctlCommon::QueuedctlResult
addTask(const QueuedProcess::QueuedProcessDefinitions &_definitions, addTask(const QueuedProcess::QueuedProcessDefinitions &_definitions,
const QString &_token); const QString &_token);
QueuedProcess::QueuedProcessDefinitions QueuedProcess::QueuedProcessDefinitions
getDefinitions(const QCommandLineParser &_parser, const bool _expandAll); getDefinitions(const QCommandLineParser &_parser, const bool _expandAll,
QueuedctlCommon::QueuedctlResult getTask(const long long _id, const QString &_token);
const QString &_property); QueuedctlCommon::QueuedctlResult
getTask(const long long _id, const QString &_property, const QString &_token);
QueuedctlCommon::QueuedctlResult getTasks(const QCommandLineParser &_parser, QueuedctlCommon::QueuedctlResult getTasks(const QCommandLineParser &_parser,
const QString &_token); const QString &_token);
void parserAdd(QCommandLineParser &_parser); void parserAdd(QCommandLineParser &_parser);

View File

@ -137,14 +137,15 @@ QString QueuedctlUser::getPassword()
QueuedctlCommon::QueuedctlResult QueuedctlCommon::QueuedctlResult
QueuedctlUser::getUser(const long long _id, const QString &_property) QueuedctlUser::getUser(const long long _id, const QString &_property,
const QString &_token)
{ {
qCDebug(LOG_APP) << "Get property" << _property << "from user" << _id; qCDebug(LOG_APP) << "Get property" << _property << "from user" << _id;
QueuedctlCommon::QueuedctlResult output; QueuedctlCommon::QueuedctlResult output;
if (_property.isEmpty()) { if (_property.isEmpty()) {
auto res = QueuedCoreAdaptor::getUser(_id); auto res = QueuedCoreAdaptor::getUser(_id, _token);
res.match( res.match(
[&output](const QVariantHash &val) { [&output](const QVariantHash &val) {
output.status = true; output.status = true;

View File

@ -34,8 +34,8 @@ QueuedctlCommon::QueuedctlResult getReport(const QCommandLineParser &_parser,
QueuedUser::QueuedUserDefinitions QueuedUser::QueuedUserDefinitions
getDefinitions(const QCommandLineParser &_parser, const bool _expandAll); getDefinitions(const QCommandLineParser &_parser, const bool _expandAll);
QString getPassword(); QString getPassword();
QueuedctlCommon::QueuedctlResult getUser(const long long _id, QueuedctlCommon::QueuedctlResult
const QString &_property); getUser(const long long _id, const QString &_property, const QString &_token);
QueuedctlCommon::QueuedctlResult getUsers(const QCommandLineParser &_parser, QueuedctlCommon::QueuedctlResult getUsers(const QCommandLineParser &_parser,
const QString &_token); const QString &_token);
void parserAdd(QCommandLineParser &_parser); void parserAdd(QCommandLineParser &_parser);