mirror of
https://github.com/bitwarden/mobile
synced 2025-12-15 15:53:44 +00:00
[PM-6655] Add username empty fallback on passkey (#3101)
* PM-6655 Added fallback "Unknown account" to passkey username and moved it so it can be shared with Android * PM-6655 Improved code lines formatting
This commit is contained in:
committed by
GitHub
parent
b931263662
commit
ff49d041be
@@ -1,8 +1,7 @@
|
|||||||
using System;
|
using Bit.Core.Enums;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using Bit.Core.Enums;
|
|
||||||
using Bit.Core.Models.Domain;
|
using Bit.Core.Models.Domain;
|
||||||
|
using Bit.Core.Resources.Localization;
|
||||||
|
using Bit.Core.Utilities;
|
||||||
|
|
||||||
namespace Bit.Core.Models.View
|
namespace Bit.Core.Models.View
|
||||||
{
|
{
|
||||||
@@ -40,4 +39,15 @@ namespace Bit.Core.Models.View
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class LoginViewExtensions
|
||||||
|
{
|
||||||
|
public static string GetMainFido2CredentialUsername(this LoginView loginView)
|
||||||
|
{
|
||||||
|
return loginView.MainFido2Credential.UserName
|
||||||
|
.FallbackOnNullOrWhiteSpace(loginView.MainFido2Credential.UserDisplayName)
|
||||||
|
.FallbackOnNullOrWhiteSpace(loginView.Username)
|
||||||
|
.FallbackOnNullOrWhiteSpace(AppResources.UnknownAccount);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7208,6 +7208,15 @@ namespace Bit.Core.Resources.Localization {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Unknown account.
|
||||||
|
/// </summary>
|
||||||
|
public static string UnknownAccount {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("UnknownAccount", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Unknown {0} error occurred..
|
/// Looks up a localized string similar to Unknown {0} error occurred..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -2942,6 +2942,9 @@ Do you want to switch to this account?</value>
|
|||||||
<data name="Passwords" xml:space="preserve">
|
<data name="Passwords" xml:space="preserve">
|
||||||
<value>Passwords</value>
|
<value>Passwords</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="UnknownAccount" xml:space="preserve">
|
||||||
|
<value>Unknown account</value>
|
||||||
|
</data>
|
||||||
<data name="SetUpAutofill" xml:space="preserve">
|
<data name="SetUpAutofill" xml:space="preserve">
|
||||||
<value>Set up auto-fill</value>
|
<value>Set up auto-fill</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Globalization;
|
||||||
using System.Globalization;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Bit.Core.Utilities
|
namespace Bit.Core.Utilities
|
||||||
@@ -30,5 +29,7 @@ namespace Bit.Core.Utilities
|
|||||||
.ToString()
|
.ToString()
|
||||||
.Normalize(NormalizationForm.FormC);
|
.Normalize(NormalizationForm.FormC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string FallbackOnNullOrWhiteSpace(this string s, string fallback) => string.IsNullOrWhiteSpace(s) ? fallback : s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using Bit.Core.Abstractions;
|
using Bit.Core.Abstractions;
|
||||||
using Bit.Core.Enums;
|
using Bit.Core.Enums;
|
||||||
using Bit.Core.Models.View;
|
using Bit.Core.Models.View;
|
||||||
|
using Bit.Core.Resources.Localization;
|
||||||
using Bit.Core.Services;
|
using Bit.Core.Services;
|
||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
using Foundation;
|
using Foundation;
|
||||||
@@ -148,19 +149,8 @@ namespace Bit.iOS.Core.Utilities
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var userName = cipher.Login.MainFido2Credential.UserName;
|
|
||||||
if (string.IsNullOrWhiteSpace(userName))
|
|
||||||
{
|
|
||||||
userName = cipher.Login.MainFido2Credential.UserDisplayName;
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(userName))
|
|
||||||
{
|
|
||||||
userName = cipher.Login.Username;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ASPasskeyCredentialIdentity(cipher.Login.MainFido2Credential.RpId,
|
return new ASPasskeyCredentialIdentity(cipher.Login.MainFido2Credential.RpId,
|
||||||
userName,
|
cipher.Login.GetMainFido2CredentialUsername(),
|
||||||
NSData.FromArray(cipher.Login.MainFido2Credential.CredentialId.GuidToRawFormat()),
|
NSData.FromArray(cipher.Login.MainFido2Credential.CredentialId.GuidToRawFormat()),
|
||||||
cipher.Login.MainFido2Credential.UserHandle,
|
cipher.Login.MainFido2Credential.UserHandle,
|
||||||
cipher.Id);
|
cipher.Id);
|
||||||
|
|||||||
Reference in New Issue
Block a user