Fix allowed things loading

thing-based-user-permissions
Simon Stürz 2025-10-27 15:53:38 +01:00
parent 82fe7c7ae3
commit cfe4328776
3 changed files with 9 additions and 2 deletions

View File

@ -311,6 +311,9 @@ JsonReply *UsersHandler::RemoveUser(const QVariantMap &params, const JsonContext
JsonReply *UsersHandler::SetUserScopes(const QVariantMap &params, const JsonContext &context)
{
Q_UNUSED(context)
qCWarning(dcJsonRpc()) << params;
QString username = params.value("username").toString();
Types::PermissionScopes scopes = Types::scopesFromStringList(params.value("scopes").toStringList());
QList<ThingId> allowedThingIds = Types::thingIdsFromStringList(params.value("allowedThingIds").toStringList());

View File

@ -39,6 +39,7 @@ class UserInfo
Q_PROPERTY(QString email READ email)
Q_PROPERTY(QString displayName READ displayName)
Q_PROPERTY(Types::PermissionScopes scopes READ scopes)
Q_PROPERTY(QList<ThingId> allowedThingIds READ allowedThingIds)
public:
UserInfo();

View File

@ -56,8 +56,11 @@ QStringList Types::thingIdsToStringList(const QList<ThingId> &thingIds)
QList<ThingId> Types::thingIdsFromStringList(const QStringList &stringList)
{
QList<ThingId> thingIds;
foreach (const QString &idString, stringList)
thingIds.append(ThingId(idString));
foreach (const QString &idString, stringList) {
if (!idString.isEmpty()) {
thingIds.append(ThingId(idString));
}
}
return thingIds;
}