Skip to content

Commit

Permalink
fix: permission for ip
Browse files Browse the repository at this point in the history
  • Loading branch information
utnapischtim committed Jul 29, 2024
1 parent 5e4fcca commit 5d84b08
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions invenio_config_tugraz/permissions/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ def needs(self, record: dict | None = None, **__: dict) -> list[Need]:
if record is None:
return []

# if record does not have singleip - return any_user
if not record.get("custom_fields", {}).get("single_ip", False):
return [any_user]

# if record has singleip, and the ip of the user matches the allowed ip
if self.check_permission():
if (
record.get("custom_fields", {}).get("single_ip", False)
and self.check_permission()
):
return [any_user]

# non of the above - return empty
Expand Down Expand Up @@ -138,12 +137,11 @@ def needs(self, record: dict | None = None, **__: dict) -> list[Need]:
if record is None:
return []

# if the record doesn't have set the ip range allowance
if not record.get("custom_fields", {}).get("ip_network", False):
return [any_user]

# if the record has set the ip_range allowance and is in the range
if self.check_permission():
if (
record.get("custom_fields", {}).get("ip_network", False)
and self.check_permission()
):
return [any_user]

# non of the above - return empty
Expand Down

0 comments on commit 5d84b08

Please sign in to comment.