From 3d16aa73eaf9cef615e84e1f8f3e0137647096cc Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Fri, 20 Sep 2024 08:15:01 -0400 Subject: [PATCH] allow admins to bypass cloud env checks --- src/main/java/cc/pulseapp/api/service/OrganizationService.java | 3 ++- src/main/java/cc/pulseapp/api/service/StatusPageService.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/cc/pulseapp/api/service/OrganizationService.java b/src/main/java/cc/pulseapp/api/service/OrganizationService.java index 5ae7504..b21f46b 100644 --- a/src/main/java/cc/pulseapp/api/service/OrganizationService.java +++ b/src/main/java/cc/pulseapp/api/service/OrganizationService.java @@ -7,6 +7,7 @@ import cc.pulseapp.api.model.IGenericResponse; import cc.pulseapp.api.model.org.DetailedOrganization; import cc.pulseapp.api.model.org.Organization; import cc.pulseapp.api.model.user.User; +import cc.pulseapp.api.model.user.UserFlag; import cc.pulseapp.api.repository.OrganizationRepository; import cc.pulseapp.api.repository.StatusPageRepository; import jakarta.annotation.Nonnull; @@ -72,7 +73,7 @@ public final class OrganizationService { throw new BadRequestException(Error.ORG_SLUG_TAKEN); } // Handle cloud environment checks - if (EnvironmentUtils.isCloud()) { + if (EnvironmentUtils.isCloud() && !owner.hasFlag(UserFlag.ADMINISTRATOR)) { if (orgRepository.findByOwnerSnowflake(owner.getSnowflake()).size() >= owner.getTier().getMaxOrganizations()) { throw new BadRequestException(Error.MAX_ORGS_REACHED); } diff --git a/src/main/java/cc/pulseapp/api/service/StatusPageService.java b/src/main/java/cc/pulseapp/api/service/StatusPageService.java index c986f8e..9ae2754 100644 --- a/src/main/java/cc/pulseapp/api/service/StatusPageService.java +++ b/src/main/java/cc/pulseapp/api/service/StatusPageService.java @@ -55,7 +55,7 @@ public final class StatusPageService { throw new BadRequestException(Error.STATUS_PAGE_NAME_TAKEN); } // Handle cloud environment checks - if (EnvironmentUtils.isCloud()) { + if (EnvironmentUtils.isCloud()/* && !owner.hasFlag(UserFlag.ADMINISTRATOR)*/) { // TODO: do UserTier#maxStatusPages check } // Create the status page and return it