fix errors
This commit is contained in:
parent
8947b9eafc
commit
fe082026c1
@ -134,16 +134,19 @@ class ImageService:
|
||||
# Apply team filtering based on user permissions
|
||||
team_filter = get_team_filter(user)
|
||||
|
||||
# Build filters
|
||||
filters = {}
|
||||
if team_filter:
|
||||
filters["team_id"] = ObjectId(team_filter)
|
||||
if collection_id:
|
||||
filters["collection_id"] = ObjectId(collection_id)
|
||||
# Convert collection_id to ObjectId if provided
|
||||
collection_obj_id = ObjectId(collection_id) if collection_id else None
|
||||
|
||||
# Get images
|
||||
images = await image_repository.list_with_filters(filters, skip, limit)
|
||||
total = await image_repository.count_with_filters(filters)
|
||||
# Get images based on user permissions
|
||||
if team_filter:
|
||||
# Regular user - filter by team
|
||||
team_obj_id = ObjectId(team_filter)
|
||||
images = await image_repository.get_by_team(team_obj_id, skip, limit, collection_obj_id)
|
||||
total = await image_repository.count_by_team(team_obj_id, collection_obj_id)
|
||||
else:
|
||||
# Admin user - can see all images
|
||||
images = await image_repository.get_all_with_pagination(skip, limit, collection_obj_id)
|
||||
total = await image_repository.count_all(collection_obj_id)
|
||||
|
||||
# Convert to responses
|
||||
image_responses = [
|
||||
|
||||
@ -30,6 +30,16 @@ class AuthorizationContext:
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Convert context to dictionary for logging"""
|
||||
if self.user is None:
|
||||
return {
|
||||
"user_id": None,
|
||||
"team_id": None,
|
||||
"is_admin": False,
|
||||
"resource_type": self.resource_type,
|
||||
"action": self.action,
|
||||
**self.metadata
|
||||
}
|
||||
|
||||
return {
|
||||
"user_id": str(self.user.id),
|
||||
"team_id": str(self.user.team_id),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user