Skip to content

Commit

Permalink
fix: permission problem
Browse files Browse the repository at this point in the history
* it is better to check in the handling function if the record is public
  or not. with this approach it applies to all datamodels and drafts and
  records.

* this change was primarly necessary for the database rebuild feature
  • Loading branch information
utnapischtim committed Jan 12, 2024
1 parent 86bea14 commit d86122a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions invenio_global_search/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def map_metadata_from_a_to_b(

record_serializer = serializer_cls()
data = record.dumps()

if data["access"]["record"] != "public":
return

obj = metadata_cls(json=data["metadata"]) if metadata_cls else data
metadata = record_serializer.dump_obj(obj)
pid = record["id"]
Expand Down Expand Up @@ -148,9 +152,6 @@ def publish(
**_: dict,
) -> None:
"""Create handler."""
if draft["access"]["record"] != "public":
return

cmp_op = ComponentOp(
record,
serializer_cls=DublinCoreJSONSerializer,
Expand Down

0 comments on commit d86122a

Please sign in to comment.