diff --git a/repos/__pycache__/user_repo.cpython-313.pyc b/repos/__pycache__/user_repo.cpython-313.pyc index 271f461..e36b862 100644 Binary files a/repos/__pycache__/user_repo.cpython-313.pyc and b/repos/__pycache__/user_repo.cpython-313.pyc differ diff --git a/repos/user_repo.py b/repos/user_repo.py index c4e5e9d..2c95703 100644 --- a/repos/user_repo.py +++ b/repos/user_repo.py @@ -20,12 +20,14 @@ class UsersRepo: async def get_user(self, user_id: int): user = await self.collection.find_one({"user_id": user_id}) - user["id"] = str(user["_id"]) + if user: + user["id"] = str(user["_id"]) return user async def get_user_by_username(self, username: str): user = await self.collection.find_one({"username": username}) - user["id"] = str(user["_id"]) + if user: + user["id"] = str(user["_id"]) return user async def create_user(self, username: str, password: str, full_name: Optional[str] = None): @@ -48,7 +50,8 @@ class UsersRepo: } result = await self.collection.insert_one(user_doc) user = await self.collection.find_one({"_id": result.inserted_id}) - user["id"] = str(user["_id"]) + if user: + user["id"] = str(user["_id"]) return user async def get_pending_users(self):