Skip to content

Commit

Permalink
add check by event short name
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed May 12, 2023
1 parent fbbaed5 commit 5ef3404
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/alfio/manager/AccessService.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ public void checkOrganizationAccess(Principal principal, int organizationId) {

public void checkEventAccess(Principal principal, int eventId) {
var orgId = eventRepository.findOrganizationIdByEventId(eventId);
checkOrganizationAccess(principal, eventId);
checkOrganizationAccess(principal, orgId);
}

public void checkEventAccess(Principal principal, String eventShortName) {
var orgId = eventRepository.findOrganizationIdByShortName(eventShortName);
checkOrganizationAccess(principal, orgId);
}

private static boolean isSystemApiUser(Principal principal) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/alfio/repository/EventRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public interface EventRepository {
@Query("select org_id from event where id = :eventId")
int findOrganizationIdByEventId(@Bind("eventId") int eventId);


@Query("select org_id from event where short_name = :shortName")
int findOrganizationIdByShortName(@Bind("shortName") String eventShortName);

default ZoneId getZoneIdByEventId(int eventId) {
return TimeZone.getTimeZone(getTimeZoneByEventId(eventId)).toZoneId();
}
Expand Down

0 comments on commit 5ef3404

Please sign in to comment.