Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor authorization checks in EventService to use UserType.LLEIDAHACKER #279

Open
wants to merge 2 commits into
base: integration
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/impl/Event/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def accept_hacker(self, event_id: int, hacker_id: int, data: BaseToken):

@BaseService.needs_service(HackerService)
def unaccept_hacker(self, event_id: int, hacker_id: int, data: BaseToken):
if not data.is_admin:
if not data.check([UserType.LLEIDAHACKER]):
raise AuthenticationException("Not authorized")
event = self.get_by_id(event_id)
if event.archived:
Expand All @@ -634,7 +634,7 @@ def unaccept_hacker(self, event_id: int, hacker_id: int, data: BaseToken):

@BaseService.needs_service('HackerGroupService')
def reject_group(self, event_id: int, group_id, data: BaseToken):
if not data.is_admin:
if not data.check([UserType.LLEIDAHACKER]):
raise AuthenticationException("Not authorized")
event = self.get_by_id(event_id)
if event.archived:
Expand All @@ -654,7 +654,7 @@ def reject_group(self, event_id: int, group_id, data: BaseToken):

@BaseService.needs_service(HackerService)
def reject_hacker(self, event_id: int, hacker_id: int, data: BaseToken):
if not data.is_admin:
if not data.check([UserType.LLEIDAHACKER]):
raise AuthenticationException("Not authorized")
event = self.get_by_id(event_id)
if event.archived:
Expand All @@ -665,7 +665,7 @@ def reject_hacker(self, event_id: int, hacker_id: int, data: BaseToken):
raise InvalidDataException("Hacker not registered")
if hacker in event.accepted_hackers:
raise InvalidDataException("Hacker already accepted")
event.rejected_hackers.remove(hacker)
event.rejected_hackers.append(hacker)
db.session.commit()
db.session.refresh(event)
db.session.refresh(hacker)
Expand Down
Loading