diff --git a/src/Api/Controllers/OrganizationsController.cs b/src/Api/Controllers/OrganizationsController.cs index eb242a475..92e9fcb87 100644 --- a/src/Api/Controllers/OrganizationsController.cs +++ b/src/Api/Controllers/OrganizationsController.cs @@ -703,8 +703,11 @@ public class OrganizationsController : Controller if (model.Enabled) { var orgUser = await _organizationUserRepository.GetByOrganizationAsync(id, userId); - orgUser.AccessSecretsManager = true; - await _organizationUserRepository.ReplaceAsync(orgUser); + if (orgUser != null) + { + orgUser.AccessSecretsManager = true; + await _organizationUserRepository.ReplaceAsync(orgUser); + } } } }