diff --git a/src/logic/mongodb_handler.py b/src/logic/mongodb_handler.py index 434e1ac..44a60fb 100644 --- a/src/logic/mongodb_handler.py +++ b/src/logic/mongodb_handler.py @@ -8,6 +8,7 @@ class Mongo: self.dyn_server = None self.dyn_db = None self.dyn_collection = None + self.dyn_client_db = None def user_db_handler(self, steamid, server, db, collection): self.dyn_server = server @@ -15,8 +16,8 @@ class Mongo: self.dyn_collection = collection try: client = pymongo.MongoClient(self.dyn_server) - self.dyn_db = client[self.dyn_db] - self.dyn_collection = self.dyn_db[self.dyn_collection] + self.dyn_client_db = client[self.dyn_db] + self.dyn_collection = self.dyn_client_db[self.dyn_collection] existing_document = self.dyn_collection.find_one({'steamid': steamid}) @@ -66,8 +67,8 @@ class Mongo: self.dyn_db = db self.dyn_collection = collection client = pymongo.MongoClient(self.dyn_server) - self.dyn_db = client[self.dyn_db] - self.dyn_collection = self.dyn_db[self.dyn_collection] + self.dyn_client_db = client[self.dyn_db] + self.dyn_collection = self.dyn_client_db[self.dyn_collection] existing_document = self.dyn_collection.find_one({'userId': userId}) if existing_document: if get_eula: @@ -91,8 +92,8 @@ class Mongo: self.dyn_db = db self.dyn_collection = collection client = pymongo.MongoClient(self.dyn_server) - self.dyn_db = client[self.dyn_db] - self.dyn_collection = self.dyn_db[self.dyn_collection] + self.dyn_client_db = client[self.dyn_db] + self.dyn_collection = self.dyn_client_db[self.dyn_collection] existing_document = self.dyn_collection.find_one({'steamid': steamid}) if existing_document: client.close() @@ -112,8 +113,8 @@ class Mongo: self.dyn_db = db self.dyn_collection = collection client = pymongo.MongoClient(self.dyn_server) - self.dyn_db = client[self.dyn_db] - self.dyn_collection = self.dyn_db[self.dyn_collection] + self.dyn_client_db = client[self.dyn_db] + self.dyn_collection = self.dyn_client_db[self.dyn_collection] if login_steam: existing_document = self.dyn_collection.find_one({'steamid': login}) else: @@ -140,8 +141,8 @@ class Mongo: self.dyn_db = db self.dyn_collection = collection client = pymongo.MongoClient(server) - self.dyn_db = client[self.dyn_db] - self.dyn_collection = self.dyn_db[self.dyn_collection] + self.dyn_client_db = client[self.dyn_db] + self.dyn_collection = self.dyn_client_db[self.dyn_collection] existing_document = self.dyn_collection.find_one({'steamid': steamid}) if existing_document: @@ -158,5 +159,27 @@ class Mongo: logger.graylog_logger(level="error", handler="mongo_write_data_with_list", message=e) return None + def get_user_info(self, userId, server, db, collection): + # TEMPORARY + try: + dyn_server = server + dyn_db = db + dyn_collection = collection + client = pymongo.MongoClient(dyn_server) + dyn_db = client[dyn_db] + dyn_collection = dyn_db[dyn_collection] + existing_document = dyn_collection.find_one({'userId': userId}) + if existing_document: + steamid = existing_document['steamid'] + token = existing_document['token'] + client.close() + return steamid, token + else: + client.close() + return "10000000aa000000gg00001", "10000000aa000000gg00001" + except Exception as e: + logger.graylog_logger(level="error", handler="mongodb_get_user_info", message=e) + return None, None + mongo = Mongo()