Fix owner field usage (#10)

Reviewed-on: #10
Co-authored-by: Madis Mägi <madis.magi@k-space.ee>
Co-committed-by: Madis Mägi <madis.magi@k-space.ee>
This commit is contained in:
Madis Mägi 2021-10-26 10:50:27 +00:00 committed by Lauri Võsandi
parent 91ae9dfcd5
commit 8a63100dc8
1 changed files with 2 additions and 2 deletions

View File

@ -24,8 +24,8 @@ async def view_doorboy_uids(request):
async for obj in db.member.find({"enabled": True}):
allowed_names.append(obj["_id"])
allowed_uids = []
async for obj in db.inventory.find({"token.uid_hash": {"$exists":True}, "inventory.owner_id": {"$exists":True}, "token.enabled": {"$exists":True}}, {"inventory.owner_id": True, "token.uid_hash": True }):
if obj["inventory"].pop("owner_id") in allowed_names:
async for obj in db.inventory.find({"token.uid_hash": {"$exists":True}, "inventory.owner": {"$exists":True}, "token.enabled": {"$exists":True}}, {"inventory.owner": True, "token.uid_hash": True }):
if obj["inventory"].pop("owner").get("foreign_id") in allowed_names:
del obj["_id"]
del obj["inventory"]
allowed_uids.append(obj)