Skip to content

Commit

Permalink
Look up compile-time localized string for "Sign in with your passkey"…
Browse files Browse the repository at this point in the history
… using the current system locale, not the current user locale, because CryptSvc renders that text and it runs as NETWORK SERVICE.
  • Loading branch information
Aldaviva committed Oct 7, 2024
1 parent ae3ab53 commit dc51fb1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions AuthenticatorChooser/I18N.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public enum Key {

public static string userLocaleName { get; } = CultureInfo.CurrentUICulture.Name;
public static string systemLocaleName { get; } = getCurrentSystemLocaleName();
private static CultureInfo systemCulture { get; } = CultureInfo.GetCultureInfo(systemLocaleName);

private static readonly FrozenDictionary<Key, IList<string>> STRINGS;
private static readonly StringComparer STRING_COMPARER = StringComparer.CurrentCulture;
Expand All @@ -44,10 +45,11 @@ static I18N() {
]);

STRINGS = new Dictionary<Key, IList<string>> {
[Key.SECURITY_KEY] = getUniqueNonNullStrings(Strings.securityKey, fidoCredProvStrings[0]),
[Key.SMARTPHONE] = getUniqueNonNullStrings(Strings.smartphone, fidoCredProvStrings[1]),
[Key.WINDOWS] = getUniqueNonNullStrings(Strings.windows, fidoCredProvStrings[2]),
[Key.SIGN_IN_WITH_YOUR_PASSKEY] = getUniqueNonNullStrings(Strings.signInWithYourPasskey, webauthnStrings[0]),
[Key.SECURITY_KEY] = getUniqueNonNullStrings(Strings.securityKey, fidoCredProvStrings[0]),
[Key.SMARTPHONE] = getUniqueNonNullStrings(Strings.smartphone, fidoCredProvStrings[1]),
[Key.WINDOWS] = getUniqueNonNullStrings(Strings.windows, fidoCredProvStrings[2]),
[Key.SIGN_IN_WITH_YOUR_PASSKEY] = getUniqueNonNullStrings(Strings.ResourceManager.GetString(nameof(Strings.signInWithYourPasskey), systemCulture),
webauthnStrings[0]),
}.ToFrozenDictionary();

static IList<string> getUniqueNonNullStrings(params string?[] strings) => strings.Compact().Distinct(STRING_COMPARER).ToList();
Expand Down

0 comments on commit dc51fb1

Please sign in to comment.