1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-06-25 10:26:02 +02:00

[PM-6655] Add null fallback cipher name on passkeys (#3116)

* PM-6655 Fixed fallback value on passkeys to take into account CipherView.Name. Also removed non-discoverable passkey filter on adding credentials to the ASStore and also added the fallback consideration on the passkeys list iOS extension

* PM-6655 Restored non-discoverable filter on credentials set for ASStore on this PR
This commit is contained in:
Federico Maccaroni 2024-03-27 19:02:28 -03:00 committed by GitHub
parent bdf2ea879d
commit 310d8b363f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 30 additions and 15 deletions

View File

@ -1,5 +1,7 @@
using Bit.Core.Enums;
using Bit.Core.Models.Domain;
using Bit.Core.Resources.Localization;
using Bit.Core.Utilities;
namespace Bit.Core.Models.View
{
@ -119,5 +121,14 @@ namespace Bit.Core.Models.View
public bool IsClonable => OrganizationId is null;
public bool HasFido2Credential => Type == CipherType.Login && Login?.HasFido2Credentials == true;
public string GetMainFido2CredentialUsername()
{
return Login?.MainFido2Credential?.UserName
.FallbackOnNullOrWhiteSpace(Login?.MainFido2Credential?.UserDisplayName)
.FallbackOnNullOrWhiteSpace(Login?.Username)
.FallbackOnNullOrWhiteSpace(Name)
.FallbackOnNullOrWhiteSpace(AppResources.UnknownAccount);
}
}
}

View File

@ -1,7 +1,5 @@
using Bit.Core.Enums;
using Bit.Core.Models.Domain;
using Bit.Core.Resources.Localization;
using Bit.Core.Utilities;
namespace Bit.Core.Models.View
{
@ -39,15 +37,4 @@ 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);
}
}
}

View File

@ -111,6 +111,21 @@ namespace Bit.iOS.Autofill.Utilities
return IsPasskeySection(indexPath.Section) || !item.ForceSectionIcon;
}
protected override string GetCipherCellSubtitle(CipherViewModel item, NSIndexPath indexPath)
{
if (!item.HasFido2Credential)
{
return base.GetCipherCellSubtitle(item, indexPath);
}
if (Context.IsPreparingListForPasskey && !IsPasskeySection(indexPath.Section))
{
return item.Username;
}
return item.CipherView?.GetMainFido2CredentialUsername() ?? item.Username;
}
public override UIView GetViewForHeader(UITableView tableView, nint section)
{
try

View File

@ -145,7 +145,7 @@ namespace Bit.iOS.Core.Utilities
}
return new ASPasskeyCredentialIdentity(cipher.Login.MainFido2Credential.RpId,
cipher.Login.GetMainFido2CredentialUsername(),
cipher.GetMainFido2CredentialUsername(),
NSData.FromArray(cipher.Login.MainFido2Credential.CredentialId.GuidToRawFormat()),
cipher.Login.MainFido2Credential.UserHandle,
cipher.Id);

View File

@ -144,7 +144,7 @@ namespace Bit.iOS.Core.Views
}
cipherCell.SetTitle(item.Name);
cipherCell.SetSubtitle(item.Username);
cipherCell.SetSubtitle(GetCipherCellSubtitle(item, indexPath));
cipherCell.UpdateMainIcon(ShouldUseMainIconAsPasskey(item, indexPath));
if (item.IsShared)
{
@ -161,6 +161,8 @@ namespace Bit.iOS.Core.Views
protected virtual bool ShouldUseMainIconAsPasskey(CipherViewModel item, NSIndexPath indexPath) => item.HasFido2Credential;
protected virtual string GetCipherCellSubtitle(CipherViewModel item, NSIndexPath indexPath) => item.Username;
public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
{
return 55;