コード例 #1
0
    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)
コード例 #2
0
 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})
コード例 #3
0
 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)
コード例 #4
0
 def getUsers():
     return list(map(modifyUsers, list(mongo.users().find())))
コード例 #5
0
 def getUserByName(username):
     if username is None:
         return None
     return mongo.users().find_one({"_id": username})
コード例 #6
0
 def getUserByApiKey(apiKey):
     if apiKey is None:
         return None
     return mongo.users().find_one({"apiKey": apiKey})