Fix role checked for endpoints not requiring authorization

This commit is contained in:
allegroai 2020-06-01 11:43:55 +03:00
parent c17b10ff1d
commit d6321588f3
2 changed files with 4 additions and 2 deletions

View File

@ -74,7 +74,9 @@ class EventBLL(object):
errors_per_type = defaultdict(int)
valid_tasks = self._get_valid_tasks(
company_id,
task_ids={event["task"] for event in events if event.get("task")},
task_ids={
event["task"] for event in events if event.get("task") is not None
},
allow_locked_tasks=allow_locked_tasks,
)
for event in events:

View File

@ -52,7 +52,7 @@ def validate_all(call: APICall, endpoint: Endpoint):
def validate_role(endpoint, call):
try:
if not endpoint.allows(call.identity.role):
if endpoint.authorize and not endpoint.allows(call.identity.role):
raise errors.forbidden.RoleNotAllowed(role=call.identity.role, allowed=endpoint.allow_roles)
except MissingIdentity:
pass