mirror of
https://github.com/bitwarden/server.git
synced 2025-04-23 14:05:10 -05:00
[PM-18858] Security Task email plurality (#5588)
* use handlebars helper for plurality of text rather than logic within the template * Remove `TaskCountPlural` - unused
This commit is contained in:
parent
aef05f5fb6
commit
7b2b62e794
@ -6,11 +6,8 @@
|
|||||||
<table border="0" cellpadding="0" cellspacing="0" width="100%"
|
<table border="0" cellpadding="0" cellspacing="0" width="100%"
|
||||||
style="padding-left:30px; padding-right: 5px; padding-top: 20px;">
|
style="padding-left:30px; padding-right: 5px; padding-top: 20px;">
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 24px; color: #ffffff; line-height: 32px; font-weight: 500; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;">
|
||||||
style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 24px; color: #ffffff; line-height: 32px; font-weight: 500; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;">
|
{{OrgName}} has identified {{TaskCount}} critical {{plurality TaskCount "login" "logins"}} that {{plurality TaskCount "requires" "require"}} a password change
|
||||||
{{OrgName}} has identified {{TaskCount}} critical login{{#if TaskCountPlural}}s{{/if}} that require{{#unless
|
|
||||||
TaskCountPlural}}s{{/unless}} a
|
|
||||||
password change
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
{{#>FullTextLayout}}
|
{{#>FullTextLayout}}
|
||||||
{{OrgName}} has identified {{TaskCount}} critical login{{#if TaskCountPlural}}s{{/if}} that require{{#unless
|
{{OrgName}} has identified {{TaskCount}} critical {{plurality TaskCount "login" "logins"}} that {{plurality TaskCount "requires" "require"}} a password change
|
||||||
TaskCountPlural}}s{{/unless}} a
|
|
||||||
password change
|
|
||||||
|
|
||||||
{{>@partial-block}}
|
{{>@partial-block}}
|
||||||
|
|
||||||
|
@ -6,8 +6,6 @@ public class SecurityTaskNotificationViewModel : BaseMailModel
|
|||||||
|
|
||||||
public int TaskCount { get; set; }
|
public int TaskCount { get; set; }
|
||||||
|
|
||||||
public bool TaskCountPlural => TaskCount != 1;
|
|
||||||
|
|
||||||
public List<string> AdminOwnerEmails { get; set; }
|
public List<string> AdminOwnerEmails { get; set; }
|
||||||
|
|
||||||
public string ReviewPasswordsUrl => $"{WebVaultUrl}/browser-extension-prompt";
|
public string ReviewPasswordsUrl => $"{WebVaultUrl}/browser-extension-prompt";
|
||||||
|
@ -794,6 +794,29 @@ public class HandlebarsMailService : IMailService
|
|||||||
|
|
||||||
writer.WriteSafeString($"{outputMessage}");
|
writer.WriteSafeString($"{outputMessage}");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Returns the singular or plural form of a word based on the provided numeric value.
|
||||||
|
Handlebars.RegisterHelper("plurality", (writer, context, parameters) =>
|
||||||
|
{
|
||||||
|
if (parameters.Length != 3)
|
||||||
|
{
|
||||||
|
writer.WriteSafeString(string.Empty);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var numeric = parameters[0];
|
||||||
|
var singularText = parameters[1].ToString();
|
||||||
|
var pluralText = parameters[2].ToString();
|
||||||
|
|
||||||
|
if (numeric is int number)
|
||||||
|
{
|
||||||
|
writer.WriteSafeString(number == 1 ? singularText : pluralText);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writer.WriteSafeString(string.Empty);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SendEmergencyAccessInviteEmailAsync(EmergencyAccess emergencyAccess, string name, string token)
|
public async Task SendEmergencyAccessInviteEmailAsync(EmergencyAccess emergencyAccess, string name, string token)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user