def deleteUser(login):
        return mongo.users().delete_one({"_id": login})


# if len(UserManager.getUsers()) == 0:#if there is no user in db, insert root/root and visitor
#   UserManager.addUser(DEFAULT_USER)
#   UserManager.addUser(VISITOR_USER)
 def updateUser(body):
     if "password" in body:
         body["passwordHash"] = _hashPassword(body["password"])
         del body["password"]
     if body.get("generateNewApiKey", False):
         body["apiKey"] = _generateApiKey()
         del body["generateNewApiKey"]
     return mongo.users().update_one({"_id": body["_id"]}, {"$set": body})
 def addUser(body):
     body["_id"] = body["login"]
     del body["login"]
     if body["accountType"] == "user":
         body["passwordHash"] = _hashPassword(body["password"])
         del body["password"]
     body["apiKey"] = _generateApiKey()
     return mongo.users().insert_one(body)
 def getUsers():
     return list(map(modifyUsers, list(mongo.users().find())))
 def getUserByName(username):
     if username is None:
         return None
     return mongo.users().find_one({"_id": username})
 def getUserByApiKey(apiKey):
     if apiKey is None:
         return None
     return mongo.users().find_one({"apiKey": apiKey})