From 7a4d83acdd18dcf1c1ea16ca4dba158b79add852 Mon Sep 17 00:00:00 2001 From: Rui Tome Date: Wed, 12 Oct 2022 17:17:56 +0100 Subject: [PATCH] =?UTF-8?q?[EC-343]=C2=A0Added=20'UseCustomPermissions'=20?= =?UTF-8?q?to=20Api=20responses?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Api/Controllers/OrganizationUsersController.cs | 11 +++++++++++ .../Response/ProfileOrganizationResponseModel.cs | 1 + .../ProfileProviderOrganizationResponseModel.cs | 1 + 3 files changed, 13 insertions(+) diff --git a/src/Api/Controllers/OrganizationUsersController.cs b/src/Api/Controllers/OrganizationUsersController.cs index 64340e3ede..b535316ec5 100644 --- a/src/Api/Controllers/OrganizationUsersController.cs +++ b/src/Api/Controllers/OrganizationUsersController.cs @@ -260,6 +260,17 @@ public class OrganizationUsersController : Controller throw new NotFoundException(); } + var organization = await _organizationRepository.GetByIdAsync(orgGuidId); + if (organization == null) + { + throw new NotFoundException(); + } + + if (model.Type == OrganizationUserType.Custom && !organization.UseCustomPermissions) + { + throw new BadRequestException("To enable custom permissions the organization must be on an Enterprise 2020 plan."); + } + var userId = _userService.GetProperUserId(User); await _organizationService.SaveUserAsync(model.ToOrganizationUser(organizationUser), userId.Value, model.Collections?.Select(c => c.ToSelectionReadOnly())); diff --git a/src/Api/Models/Response/ProfileOrganizationResponseModel.cs b/src/Api/Models/Response/ProfileOrganizationResponseModel.cs index 4285ae432b..e0292993b3 100644 --- a/src/Api/Models/Response/ProfileOrganizationResponseModel.cs +++ b/src/Api/Models/Response/ProfileOrganizationResponseModel.cs @@ -73,6 +73,7 @@ public class ProfileOrganizationResponseModel : ResponseModel public bool UseApi { get; set; } public bool UseResetPassword { get; set; } public bool UsersGetPremium { get; set; } + public bool UseCustomPermissions { get; set; } public bool SelfHost { get; set; } public int? Seats { get; set; } public short? MaxCollections { get; set; } diff --git a/src/Api/Models/Response/ProfileProviderOrganizationResponseModel.cs b/src/Api/Models/Response/ProfileProviderOrganizationResponseModel.cs index a660662fac..88c41d99c0 100644 --- a/src/Api/Models/Response/ProfileProviderOrganizationResponseModel.cs +++ b/src/Api/Models/Response/ProfileProviderOrganizationResponseModel.cs @@ -22,6 +22,7 @@ public class ProfileProviderOrganizationResponseModel : ProfileOrganizationRespo UseApi = organization.UseApi; UseResetPassword = organization.UseResetPassword; UsersGetPremium = organization.UsersGetPremium; + UseCustomPermissions = organization.UseCustomPermissions; SelfHost = organization.SelfHost; Seats = organization.Seats; MaxCollections = organization.MaxCollections;