Skip to content

Commit

Permalink
Merge branch 'feature/maui-migration-passkeys' into vault/pm-6798/fix…
Browse files Browse the repository at this point in the history
…-account-switch-on-ios-autofill
  • Loading branch information
vvolkgang committed Mar 27, 2024
2 parents 9fb805d + 310d8b3 commit d9642b6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
11 changes: 11 additions & 0 deletions src/Core/Models/View/CipherView.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -119,5 +121,14 @@ public string LinkedFieldI18nKey(LinkedIdType id)
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);
}
}
}
13 changes: 0 additions & 13 deletions src/Core/Models/View/LoginView.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -39,15 +37,4 @@ public LoginView(Login l)
};
}
}

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);
}
}
}
15 changes: 15 additions & 0 deletions src/iOS.Autofill/Utilities/BaseLoginListTableSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,21 @@ protected override bool ShouldUseMainIconAsPasskey(CipherViewModel item, NSIndex
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
Expand Down
7 changes: 1 addition & 6 deletions src/iOS.Core/Utilities/ASHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,8 @@ public static async Task<bool> IsAutofillEnabledAsync()
return ToPasswordCredentialIdentity(cipher);
}

if (!cipher.Login.MainFido2Credential.DiscoverableValue)
{
return null;
}

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);
Expand Down
4 changes: 3 additions & 1 deletion src/iOS.Core/Views/ExtensionTableSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public override void WillDisplay(UITableView tableView, UITableViewCell cell, NS
}

cipherCell.SetTitle(item.Name);
cipherCell.SetSubtitle(item.Username);
cipherCell.SetSubtitle(GetCipherCellSubtitle(item, indexPath));
cipherCell.UpdateMainIcon(ShouldUseMainIconAsPasskey(item, indexPath));
if (item.IsShared)
{
Expand All @@ -161,6 +161,8 @@ public override void WillDisplay(UITableView tableView, UITableViewCell cell, NS

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;
Expand Down

0 comments on commit d9642b6

Please sign in to comment.