mirror of
https://github.com/bitwarden/server
synced 2026-01-08 19:43:34 +00:00
Added conditional subject and button text to invite email. (#6304)
* Added conditional subject and button text to invite email. * Added feature flag.
This commit is contained in:
@@ -15,6 +15,7 @@ public class OrganizationInvitesInfo
|
||||
bool orgSsoLoginRequiredPolicyEnabled,
|
||||
IEnumerable<(OrganizationUser orgUser, ExpiringToken token)> orgUserTokenPairs,
|
||||
Dictionary<Guid, bool> orgUserHasExistingUserDict,
|
||||
bool isSubjectFeatureEnabled = false,
|
||||
bool initOrganization = false
|
||||
)
|
||||
{
|
||||
@@ -29,6 +30,8 @@ public class OrganizationInvitesInfo
|
||||
|
||||
OrgUserTokenPairs = orgUserTokenPairs;
|
||||
OrgUserHasExistingUserDict = orgUserHasExistingUserDict;
|
||||
|
||||
IsSubjectFeatureEnabled = isSubjectFeatureEnabled;
|
||||
}
|
||||
|
||||
public string OrganizationName { get; }
|
||||
@@ -38,6 +41,8 @@ public class OrganizationInvitesInfo
|
||||
public string OrgSsoIdentifier { get; }
|
||||
public bool OrgSsoLoginRequiredPolicyEnabled { get; }
|
||||
|
||||
public bool IsSubjectFeatureEnabled { get; }
|
||||
|
||||
public IEnumerable<(OrganizationUser OrgUser, ExpiringToken Token)> OrgUserTokenPairs { get; }
|
||||
public Dictionary<Guid, bool> OrgUserHasExistingUserDict { get; }
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ public class OrganizationUserInvitedViewModel : BaseTitleContactUsMailModel
|
||||
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 ",
|
||||
@@ -48,6 +49,45 @@ public class OrganizationUserInvitedViewModel : BaseTitleContactUsMailModel
|
||||
};
|
||||
}
|
||||
|
||||
public static OrganizationUserInvitedViewModel CreateFromInviteInfo_v2(
|
||||
OrganizationInvitesInfo orgInvitesInfo,
|
||||
OrganizationUser orgUser,
|
||||
ExpiringToken expiringToken,
|
||||
GlobalSettings globalSettings)
|
||||
{
|
||||
const string freeOrgTitle = "A Bitwarden member invited you to an organization. " +
|
||||
"Join now to start securing your passwords!";
|
||||
|
||||
var userHasExistingUser = orgInvitesInfo.OrgUserHasExistingUserDict[orgUser.Id];
|
||||
|
||||
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 = userHasExistingUser,
|
||||
JoinOrganizationButtonText = userHasExistingUser || orgInvitesInfo.IsFreeOrg ? "Accept invitation" : "Finish account setup",
|
||||
IsFreeOrg = orgInvitesInfo.IsFreeOrg
|
||||
};
|
||||
}
|
||||
|
||||
public string OrganizationName { get; set; }
|
||||
public string OrganizationId { get; set; }
|
||||
public string OrganizationUserId { get; set; }
|
||||
@@ -60,6 +100,8 @@ public class OrganizationUserInvitedViewModel : BaseTitleContactUsMailModel
|
||||
public bool OrgSsoEnabled { get; set; }
|
||||
public bool OrgSsoLoginRequiredPolicyEnabled { get; set; }
|
||||
public bool OrgUserHasExistingUser { get; set; }
|
||||
public string JoinOrganizationButtonText { get; set; } = "Join Organization";
|
||||
public bool IsFreeOrg { get; set; }
|
||||
|
||||
public string Url
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user