From 0eccfb878477db2a14e4b9541cb6a215c6020c7b Mon Sep 17 00:00:00 2001 From: Addison Beck Date: Tue, 27 Oct 2020 10:28:41 -0400 Subject: [PATCH] changed all OnlyOrg wording to be SingleOrg instead (#974) * changed all OnlyOrg wording to be SingleOrg instead * missed an OnlyOrg to change to SingleOrg --- .../src/Portal/Controllers/PoliciesController.cs | 2 +- bitwarden_license/src/Portal/Models/PolicyEditModel.cs | 2 +- bitwarden_license/src/Portal/Models/PolicyModel.cs | 6 +++--- bitwarden_license/src/Portal/Views/Policies/Edit.cshtml | 4 ++-- src/Api/Controllers/OrganizationsController.cs | 4 ++-- src/Core/Enums/PolicyType.cs | 2 +- ...=> OrganizationUserRemovedForPolicySingleOrg.html.hbs} | 0 ...=> OrganizationUserRemovedForPolicySingleOrg.text.hbs} | 0 ...OrganizationUserRemovedForPolicySingleOrgViewModel.cs} | 2 +- src/Core/Resources/SharedResources.en.resx | 8 ++++---- src/Core/Services/IMailService.cs | 2 +- .../Services/Implementations/HandlebarsMailService.cs | 8 ++++---- src/Core/Services/Implementations/OrganizationService.cs | 8 ++++---- src/Core/Services/Implementations/PolicyService.cs | 4 ++-- src/Core/Services/NoopImplementations/NoopMailService.cs | 2 +- 15 files changed, 27 insertions(+), 27 deletions(-) rename src/Core/MailTemplates/Handlebars/{OrganizationUserRemovedForPolicyOnlyOrg.html.hbs => OrganizationUserRemovedForPolicySingleOrg.html.hbs} (100%) rename src/Core/MailTemplates/Handlebars/{OrganizationUserRemovedForPolicyOnlyOrg.text.hbs => OrganizationUserRemovedForPolicySingleOrg.text.hbs} (100%) rename src/Core/Models/Mail/{OrganizationUserRemovedForPolicyOnlyOrgViewModel.cs => OrganizationUserRemovedForPolicySingleOrgViewModel.cs} (55%) diff --git a/bitwarden_license/src/Portal/Controllers/PoliciesController.cs b/bitwarden_license/src/Portal/Controllers/PoliciesController.cs index 41edf0b39..535d77765 100644 --- a/bitwarden_license/src/Portal/Controllers/PoliciesController.cs +++ b/bitwarden_license/src/Portal/Controllers/PoliciesController.cs @@ -135,7 +135,7 @@ namespace Bit.Portal.Controllers case PolicyType.MasterPassword: case PolicyType.PasswordGenerator: case PolicyType.TwoFactorAuthentication: - case PolicyType.OnlyOrg: + case PolicyType.SingleOrg: break; case PolicyType.RequireSso: diff --git a/bitwarden_license/src/Portal/Models/PolicyEditModel.cs b/bitwarden_license/src/Portal/Models/PolicyEditModel.cs index 671c5ef68..0ed75eab9 100644 --- a/bitwarden_license/src/Portal/Models/PolicyEditModel.cs +++ b/bitwarden_license/src/Portal/Models/PolicyEditModel.cs @@ -81,7 +81,7 @@ namespace Bit.Portal.Models case PolicyType.PasswordGenerator: existingPolicy.Data = JsonSerializer.Serialize(PasswordGeneratorDataModel, options); break; - case PolicyType.OnlyOrg: + case PolicyType.SingleOrg: case PolicyType.TwoFactorAuthentication: case PolicyType.RequireSso: break; diff --git a/bitwarden_license/src/Portal/Models/PolicyModel.cs b/bitwarden_license/src/Portal/Models/PolicyModel.cs index 4877dc5c7..057ec18c0 100644 --- a/bitwarden_license/src/Portal/Models/PolicyModel.cs +++ b/bitwarden_license/src/Portal/Models/PolicyModel.cs @@ -32,9 +32,9 @@ namespace Bit.Portal.Models DescriptionKey = "PasswordGeneratorDescription"; break; - case PolicyType.OnlyOrg: - NameKey = "OnlyOrganization"; - DescriptionKey = "OnlyOrganizationDescription"; + case PolicyType.SingleOrg: + NameKey = "SingleOrganization"; + DescriptionKey = "SingleOrganizationDescription"; break; case PolicyType.RequireSso: diff --git a/bitwarden_license/src/Portal/Views/Policies/Edit.cshtml b/bitwarden_license/src/Portal/Views/Policies/Edit.cshtml index 71db37a0c..607dfab8d 100644 --- a/bitwarden_license/src/Portal/Views/Policies/Edit.cshtml +++ b/bitwarden_license/src/Portal/Views/Policies/Edit.cshtml @@ -22,14 +22,14 @@ } - @if (Model.PolicyType == PolicyType.OnlyOrg) + @if (Model.PolicyType == PolicyType.SingleOrg) { } diff --git a/src/Api/Controllers/OrganizationsController.cs b/src/Api/Controllers/OrganizationsController.cs index 969a99d15..6568efe77 100644 --- a/src/Api/Controllers/OrganizationsController.cs +++ b/src/Api/Controllers/OrganizationsController.cs @@ -161,7 +161,7 @@ namespace Bit.Api.Controllers } var policies = await _policyRepository.GetManyByUserIdAsync(user.Id); - if (policies.Any(policy => policy.Type == PolicyType.OnlyOrg)) + if (policies.Any(policy => policy.Type == PolicyType.SingleOrg)) { throw new Exception("You may not create an organization. You belong to an organization " + "which has a policy that prohibits you from being a member of any other organization."); @@ -189,7 +189,7 @@ namespace Bit.Api.Controllers } var policies = await _policyRepository.GetManyByUserIdAsync(user.Id); - if (policies.Any(policy => policy.Type == PolicyType.OnlyOrg)) + if (policies.Any(policy => policy.Type == PolicyType.SingleOrg)) { throw new Exception("You may not create an organization. You belong to an organization " + "which has a policy that prohibits you from being a member of any other organization."); diff --git a/src/Core/Enums/PolicyType.cs b/src/Core/Enums/PolicyType.cs index 783a92ffa..bfd9514f9 100644 --- a/src/Core/Enums/PolicyType.cs +++ b/src/Core/Enums/PolicyType.cs @@ -5,7 +5,7 @@ TwoFactorAuthentication = 0, MasterPassword = 1, PasswordGenerator = 2, - OnlyOrg = 3, + SingleOrg = 3, RequireSso = 4, } } diff --git a/src/Core/MailTemplates/Handlebars/OrganizationUserRemovedForPolicyOnlyOrg.html.hbs b/src/Core/MailTemplates/Handlebars/OrganizationUserRemovedForPolicySingleOrg.html.hbs similarity index 100% rename from src/Core/MailTemplates/Handlebars/OrganizationUserRemovedForPolicyOnlyOrg.html.hbs rename to src/Core/MailTemplates/Handlebars/OrganizationUserRemovedForPolicySingleOrg.html.hbs diff --git a/src/Core/MailTemplates/Handlebars/OrganizationUserRemovedForPolicyOnlyOrg.text.hbs b/src/Core/MailTemplates/Handlebars/OrganizationUserRemovedForPolicySingleOrg.text.hbs similarity index 100% rename from src/Core/MailTemplates/Handlebars/OrganizationUserRemovedForPolicyOnlyOrg.text.hbs rename to src/Core/MailTemplates/Handlebars/OrganizationUserRemovedForPolicySingleOrg.text.hbs diff --git a/src/Core/Models/Mail/OrganizationUserRemovedForPolicyOnlyOrgViewModel.cs b/src/Core/Models/Mail/OrganizationUserRemovedForPolicySingleOrgViewModel.cs similarity index 55% rename from src/Core/Models/Mail/OrganizationUserRemovedForPolicyOnlyOrgViewModel.cs rename to src/Core/Models/Mail/OrganizationUserRemovedForPolicySingleOrgViewModel.cs index d1425d00f..9a92f0e0b 100644 --- a/src/Core/Models/Mail/OrganizationUserRemovedForPolicyOnlyOrgViewModel.cs +++ b/src/Core/Models/Mail/OrganizationUserRemovedForPolicySingleOrgViewModel.cs @@ -1,6 +1,6 @@ namespace Bit.Core.Models.Mail { - public class OrganizationUserRemovedForPolicyOnlyOrgViewModel : BaseMailModel + public class OrganizationUserRemovedForPolicySingleOrgViewModel : BaseMailModel { public string OrganizationName { get; set; } } diff --git a/src/Core/Resources/SharedResources.en.resx b/src/Core/Resources/SharedResources.en.resx index 8c67749d0..2f0fbc942 100644 --- a/src/Core/Resources/SharedResources.en.resx +++ b/src/Core/Resources/SharedResources.en.resx @@ -539,13 +539,13 @@ OIDC Redirect Behavior - - Only Organization + + Single Organization - + Restrict users from being able to join any other organizations. - + Organization members who are already a part of another organization will be removed from this organization and will receive an email notifying them about the change. diff --git a/src/Core/Services/IMailService.cs b/src/Core/Services/IMailService.cs index 9b22da00f..88459ece9 100644 --- a/src/Core/Services/IMailService.cs +++ b/src/Core/Services/IMailService.cs @@ -28,6 +28,6 @@ namespace Bit.Core.Services Task SendLicenseExpiredAsync(IEnumerable emails, string organizationName = null); Task SendNewDeviceLoggedInEmail(string email, string deviceType, DateTime timestamp, string ip); Task SendRecoverTwoFactorEmail(string email, DateTime timestamp, string ip); - Task SendOrganizationUserRemovedForPolicyOnlyOrgEmailAsync(string organizationName, string email); + Task SendOrganizationUserRemovedForPolicySingleOrgEmailAsync(string organizationName, string email); } } diff --git a/src/Core/Services/Implementations/HandlebarsMailService.cs b/src/Core/Services/Implementations/HandlebarsMailService.cs index 289153b09..1a6d05c0a 100644 --- a/src/Core/Services/Implementations/HandlebarsMailService.cs +++ b/src/Core/Services/Implementations/HandlebarsMailService.cs @@ -326,17 +326,17 @@ namespace Bit.Core.Services await _mailDeliveryService.SendEmailAsync(message); } - public async Task SendOrganizationUserRemovedForPolicyOnlyOrgEmailAsync(string organizationName, string email) + public async Task SendOrganizationUserRemovedForPolicySingleOrgEmailAsync(string organizationName, string email) { var message = CreateDefaultMessage($"You have been removed from {organizationName}", email); - var model = new OrganizationUserRemovedForPolicyOnlyOrgViewModel + var model = new OrganizationUserRemovedForPolicySingleOrgViewModel { OrganizationName = CoreHelpers.SanitizeForEmail(organizationName), WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash, SiteName = _globalSettings.SiteName }; - await AddMessageContentAsync(message, "OrganizationUserRemovedForPolicyOnlyOrg", model); - message.Category = "OrganizationUserRemovedForPolicyOnlyOrg"; + await AddMessageContentAsync(message, "OrganizationUserRemovedForPolicySingleOrg", model); + message.Category = "OrganizationUserRemovedForPolicySingleOrg"; await _mailDeliveryService.SendEmailAsync(message); } diff --git a/src/Core/Services/Implementations/OrganizationService.cs b/src/Core/Services/Implementations/OrganizationService.cs index 0342f66e2..ebf9f1706 100644 --- a/src/Core/Services/Implementations/OrganizationService.cs +++ b/src/Core/Services/Implementations/OrganizationService.cs @@ -1148,12 +1148,12 @@ namespace Bit.Core.Services var userOrgs = await _organizationUserRepository.GetManyByUserAsync(user.Id); if (userOrgs.Any(ou => ou.OrganizationId != orgUser.OrganizationId && ou.Status != OrganizationUserStatusType.Invited)) { - if (await hasPolicyAsync(PolicyType.OnlyOrg)) + if (await hasPolicyAsync(PolicyType.SingleOrg)) { throw new BadRequestException("You may not join this organization until you leave or remove " + "all other organizations."); } - if (await hasPolicyAsync(PolicyType.OnlyOrg, true)) + if (await hasPolicyAsync(PolicyType.SingleOrg, true)) { throw new BadRequestException("You cannot join this organization because you are a member of " + "an organization which forbids it"); @@ -1209,8 +1209,8 @@ namespace Bit.Core.Services throw new BadRequestException("User does not have two-step login enabled."); } - var usingOnlyOrgPolicy = policies.Any(p => p.Type == PolicyType.OnlyOrg && p.Enabled); - if (usingOnlyOrgPolicy) + var usingSingleOrgPolicy = policies.Any(p => p.Type == PolicyType.SingleOrg && p.Enabled); + if (usingSingleOrgPolicy) { var userOrgs = await _organizationUserRepository.GetManyByUserAsync(user.Id); if (userOrgs.Any(ou => ou.OrganizationId != organizationId && ou.Status != OrganizationUserStatusType.Invited)) diff --git a/src/Core/Services/Implementations/PolicyService.cs b/src/Core/Services/Implementations/PolicyService.cs index a9a59cdc3..25e28239f 100644 --- a/src/Core/Services/Implementations/PolicyService.cs +++ b/src/Core/Services/Implementations/PolicyService.cs @@ -76,7 +76,7 @@ namespace Bit.Core.Services } } break; - case Enums.PolicyType.OnlyOrg: + case Enums.PolicyType.SingleOrg: var userOrgs = await _organizationUserRepository.GetManyByManyUsersAsync( removableOrgUsers.Select(ou => ou.UserId.Value)); foreach (var orgUser in removableOrgUsers) @@ -86,7 +86,7 @@ namespace Bit.Core.Services organization = organization ?? await _organizationRepository.GetByIdAsync(policy.OrganizationId); await organizationService.DeleteUserAsync(policy.OrganizationId, orgUser.Id, savingUserId); - await _mailService.SendOrganizationUserRemovedForPolicyOnlyOrgEmailAsync( + await _mailService.SendOrganizationUserRemovedForPolicySingleOrgEmailAsync( organization.Name, orgUser.Email); } } diff --git a/src/Core/Services/NoopImplementations/NoopMailService.cs b/src/Core/Services/NoopImplementations/NoopMailService.cs index 86634f4cd..a0f8e2aca 100644 --- a/src/Core/Services/NoopImplementations/NoopMailService.cs +++ b/src/Core/Services/NoopImplementations/NoopMailService.cs @@ -103,7 +103,7 @@ namespace Bit.Core.Services return Task.FromResult(0); } - public Task SendOrganizationUserRemovedForPolicyOnlyOrgEmailAsync(string organizationName, string email) + public Task SendOrganizationUserRemovedForPolicySingleOrgEmailAsync(string organizationName, string email) { return Task.FromResult(0); }