Update user repository implementation.
This commit is contained in:
Binary file not shown.
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user