mirror of
https://github.com/bitwarden/server
synced 2025-12-06 00:03:34 +00:00
chore: remove FF, references, and restructure code, refs PM-24373 (#6353)
This commit is contained in:
@@ -22,8 +22,7 @@ public class SendOrganizationInvitesCommand(
|
|||||||
IPolicyRepository policyRepository,
|
IPolicyRepository policyRepository,
|
||||||
IOrgUserInviteTokenableFactory orgUserInviteTokenableFactory,
|
IOrgUserInviteTokenableFactory orgUserInviteTokenableFactory,
|
||||||
IDataProtectorTokenFactory<OrgUserInviteTokenable> dataProtectorTokenFactory,
|
IDataProtectorTokenFactory<OrgUserInviteTokenable> dataProtectorTokenFactory,
|
||||||
IMailService mailService,
|
IMailService mailService) : ISendOrganizationInvitesCommand
|
||||||
IFeatureService featureService) : ISendOrganizationInvitesCommand
|
|
||||||
{
|
{
|
||||||
public async Task SendInvitesAsync(SendInvitesRequest request)
|
public async Task SendInvitesAsync(SendInvitesRequest request)
|
||||||
{
|
{
|
||||||
@@ -72,15 +71,12 @@ public class SendOrganizationInvitesCommand(
|
|||||||
|
|
||||||
var orgUsersWithExpTokens = orgUsers.Select(MakeOrgUserExpiringTokenPair);
|
var orgUsersWithExpTokens = orgUsers.Select(MakeOrgUserExpiringTokenPair);
|
||||||
|
|
||||||
var isSubjectFeatureEnabled = featureService.IsEnabled(FeatureFlagKeys.InviteEmailImprovements);
|
|
||||||
|
|
||||||
return new OrganizationInvitesInfo(
|
return new OrganizationInvitesInfo(
|
||||||
organization,
|
organization,
|
||||||
orgSsoEnabled,
|
orgSsoEnabled,
|
||||||
orgSsoLoginRequiredPolicyEnabled,
|
orgSsoLoginRequiredPolicyEnabled,
|
||||||
orgUsersWithExpTokens,
|
orgUsersWithExpTokens,
|
||||||
orgUserHasExistingUserDict,
|
orgUserHasExistingUserDict,
|
||||||
isSubjectFeatureEnabled,
|
|
||||||
initOrganization
|
initOrganization
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,6 @@ public static class FeatureFlagKeys
|
|||||||
public const string CipherRepositoryBulkResourceCreation = "pm-24951-cipher-repository-bulk-resource-creation-service";
|
public const string CipherRepositoryBulkResourceCreation = "pm-24951-cipher-repository-bulk-resource-creation-service";
|
||||||
public const string CollectionVaultRefactor = "pm-25030-resolve-ts-upgrade-errors";
|
public const string CollectionVaultRefactor = "pm-25030-resolve-ts-upgrade-errors";
|
||||||
public const string DeleteClaimedUserAccountRefactor = "pm-25094-refactor-delete-managed-organization-user-command";
|
public const string DeleteClaimedUserAccountRefactor = "pm-25094-refactor-delete-managed-organization-user-command";
|
||||||
public const string InviteEmailImprovements = "pm-25644-update-join-organization-subject-line";
|
|
||||||
|
|
||||||
/* Auth Team */
|
/* Auth Team */
|
||||||
public const string TwoFactorExtensionDataPersistence = "pm-9115-two-factor-extension-data-persistence";
|
public const string TwoFactorExtensionDataPersistence = "pm-9115-two-factor-extension-data-persistence";
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ public class OrganizationInvitesInfo
|
|||||||
bool orgSsoLoginRequiredPolicyEnabled,
|
bool orgSsoLoginRequiredPolicyEnabled,
|
||||||
IEnumerable<(OrganizationUser orgUser, ExpiringToken token)> orgUserTokenPairs,
|
IEnumerable<(OrganizationUser orgUser, ExpiringToken token)> orgUserTokenPairs,
|
||||||
Dictionary<Guid, bool> orgUserHasExistingUserDict,
|
Dictionary<Guid, bool> orgUserHasExistingUserDict,
|
||||||
bool isSubjectFeatureEnabled = false,
|
|
||||||
bool initOrganization = false
|
bool initOrganization = false
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -30,8 +29,6 @@ public class OrganizationInvitesInfo
|
|||||||
|
|
||||||
OrgUserTokenPairs = orgUserTokenPairs;
|
OrgUserTokenPairs = orgUserTokenPairs;
|
||||||
OrgUserHasExistingUserDict = orgUserHasExistingUserDict;
|
OrgUserHasExistingUserDict = orgUserHasExistingUserDict;
|
||||||
|
|
||||||
IsSubjectFeatureEnabled = isSubjectFeatureEnabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string OrganizationName { get; }
|
public string OrganizationName { get; }
|
||||||
@@ -40,9 +37,6 @@ public class OrganizationInvitesInfo
|
|||||||
public bool OrgSsoEnabled { get; }
|
public bool OrgSsoEnabled { get; }
|
||||||
public string OrgSsoIdentifier { get; }
|
public string OrgSsoIdentifier { get; }
|
||||||
public bool OrgSsoLoginRequiredPolicyEnabled { get; }
|
public bool OrgSsoLoginRequiredPolicyEnabled { get; }
|
||||||
|
|
||||||
public bool IsSubjectFeatureEnabled { get; }
|
|
||||||
|
|
||||||
public IEnumerable<(OrganizationUser OrgUser, ExpiringToken Token)> OrgUserTokenPairs { get; }
|
public IEnumerable<(OrganizationUser OrgUser, ExpiringToken Token)> OrgUserTokenPairs { get; }
|
||||||
public Dictionary<Guid, bool> OrgUserHasExistingUserDict { get; }
|
public Dictionary<Guid, bool> OrgUserHasExistingUserDict { get; }
|
||||||
|
|
||||||
|
|||||||
@@ -20,40 +20,6 @@ public class OrganizationUserInvitedViewModel : BaseTitleContactUsMailModel
|
|||||||
OrganizationUser orgUser,
|
OrganizationUser orgUser,
|
||||||
ExpiringToken expiringToken,
|
ExpiringToken expiringToken,
|
||||||
GlobalSettings globalSettings)
|
GlobalSettings globalSettings)
|
||||||
{
|
|
||||||
var freeOrgTitle = "A Bitwarden member invited you to an organization. Join now to start securing your passwords!";
|
|
||||||
|
|
||||||
return new OrganizationUserInvitedViewModel
|
|
||||||
{
|
|
||||||
TitleFirst = orgInvitesInfo.IsFreeOrg ? freeOrgTitle : "Join ",
|
|
||||||
TitleSecondBold =
|
|
||||||
orgInvitesInfo.IsFreeOrg
|
|
||||||
? string.Empty
|
|
||||||
: CoreHelpers.SanitizeForEmail(orgInvitesInfo.OrganizationName, false),
|
|
||||||
TitleThird = orgInvitesInfo.IsFreeOrg ? string.Empty : " on Bitwarden and start securing your passwords!",
|
|
||||||
OrganizationName = CoreHelpers.SanitizeForEmail(orgInvitesInfo.OrganizationName, false),
|
|
||||||
Email = WebUtility.UrlEncode(orgUser.Email),
|
|
||||||
OrganizationId = orgUser.OrganizationId.ToString(),
|
|
||||||
OrganizationUserId = orgUser.Id.ToString(),
|
|
||||||
Token = WebUtility.UrlEncode(expiringToken.Token),
|
|
||||||
ExpirationDate =
|
|
||||||
$"{expiringToken.ExpirationDate.ToLongDateString()} {expiringToken.ExpirationDate.ToShortTimeString()} UTC",
|
|
||||||
OrganizationNameUrlEncoded = WebUtility.UrlEncode(orgInvitesInfo.OrganizationName),
|
|
||||||
WebVaultUrl = globalSettings.BaseServiceUri.VaultWithHash,
|
|
||||||
SiteName = globalSettings.SiteName,
|
|
||||||
InitOrganization = orgInvitesInfo.InitOrganization,
|
|
||||||
OrgSsoIdentifier = orgInvitesInfo.OrgSsoIdentifier,
|
|
||||||
OrgSsoEnabled = orgInvitesInfo.OrgSsoEnabled,
|
|
||||||
OrgSsoLoginRequiredPolicyEnabled = orgInvitesInfo.OrgSsoLoginRequiredPolicyEnabled,
|
|
||||||
OrgUserHasExistingUser = orgInvitesInfo.OrgUserHasExistingUserDict[orgUser.Id]
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OrganizationUserInvitedViewModel CreateFromInviteInfo_v2(
|
|
||||||
OrganizationInvitesInfo orgInvitesInfo,
|
|
||||||
OrganizationUser orgUser,
|
|
||||||
ExpiringToken expiringToken,
|
|
||||||
GlobalSettings globalSettings)
|
|
||||||
{
|
{
|
||||||
const string freeOrgTitle = "A Bitwarden member invited you to an organization. " +
|
const string freeOrgTitle = "A Bitwarden member invited you to an organization. " +
|
||||||
"Join now to start securing your passwords!";
|
"Join now to start securing your passwords!";
|
||||||
|
|||||||
@@ -355,11 +355,8 @@ public class HandlebarsMailService : IMailService
|
|||||||
{
|
{
|
||||||
Debug.Assert(orgUserTokenPair.OrgUser.Email is not null);
|
Debug.Assert(orgUserTokenPair.OrgUser.Email is not null);
|
||||||
|
|
||||||
var orgUserInviteViewModel = orgInvitesInfo.IsSubjectFeatureEnabled
|
var orgUserInviteViewModel = OrganizationUserInvitedViewModel.CreateFromInviteInfo(orgInvitesInfo, orgUserTokenPair.OrgUser,
|
||||||
? OrganizationUserInvitedViewModel.CreateFromInviteInfo_v2(
|
orgUserTokenPair.Token, _globalSettings);
|
||||||
orgInvitesInfo, orgUserTokenPair.OrgUser, orgUserTokenPair.Token, _globalSettings)
|
|
||||||
: OrganizationUserInvitedViewModel.CreateFromInviteInfo(orgInvitesInfo, orgUserTokenPair.OrgUser,
|
|
||||||
orgUserTokenPair.Token, _globalSettings);
|
|
||||||
|
|
||||||
return CreateMessage(orgUserTokenPair.OrgUser.Email, orgUserInviteViewModel);
|
return CreateMessage(orgUserTokenPair.OrgUser.Email, orgUserInviteViewModel);
|
||||||
});
|
});
|
||||||
@@ -369,20 +366,15 @@ public class HandlebarsMailService : IMailService
|
|||||||
|
|
||||||
MailQueueMessage CreateMessage(string email, OrganizationUserInvitedViewModel model)
|
MailQueueMessage CreateMessage(string email, OrganizationUserInvitedViewModel model)
|
||||||
{
|
{
|
||||||
var subject = $"Join {model.OrganizationName}";
|
ArgumentNullException.ThrowIfNull(model);
|
||||||
|
|
||||||
if (orgInvitesInfo.IsSubjectFeatureEnabled)
|
var subject = model! switch
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(model);
|
{ IsFreeOrg: true, OrgUserHasExistingUser: true } => "You have been invited to a Bitwarden Organization",
|
||||||
|
{ IsFreeOrg: true, OrgUserHasExistingUser: false } => "You have been invited to Bitwarden Password Manager",
|
||||||
subject = model! switch
|
{ IsFreeOrg: false, OrgUserHasExistingUser: true } => $"{model.OrganizationName} invited you to their Bitwarden organization",
|
||||||
{
|
{ IsFreeOrg: false, OrgUserHasExistingUser: false } => $"{model.OrganizationName} set up a Bitwarden account for you"
|
||||||
{ IsFreeOrg: true, OrgUserHasExistingUser: true } => "You have been invited to a Bitwarden Organization",
|
};
|
||||||
{ IsFreeOrg: true, OrgUserHasExistingUser: false } => "You have been invited to Bitwarden Password Manager",
|
|
||||||
{ IsFreeOrg: false, OrgUserHasExistingUser: true } => $"{model.OrganizationName} invited you to their Bitwarden organization",
|
|
||||||
{ IsFreeOrg: false, OrgUserHasExistingUser: false } => $"{model.OrganizationName} set up a Bitwarden account for you"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var message = CreateDefaultMessage(subject, email);
|
var message = CreateDefaultMessage(subject, email);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user