Skip to content

Commit 08b2225

Browse files
authored
Revert "PAS-536 | Add support for AuthenticatorDisplayName (#713)"
This reverts commit b7165e0.
1 parent 9514b52 commit 08b2225

15 files changed

+242
-1271
lines changed

src/AdminConsole/Components/Shared/Credentials.razor

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<dl class="mt-2">
2424
<CardSummaryProperty Label="Created:" Value="cred.CreatedAt"></CardSummaryProperty>
2525
<CardSummaryProperty Label="Last used:" Value="cred.LastUsedAt"></CardSummaryProperty>
26-
26+
2727
@if (!HideDetails)
2828
{
2929
<div class="credential-card-summary-footer">
@@ -53,8 +53,7 @@
5353
<CardDetailsProperty Label="Counter" Value="@cred.SignatureCounter" class="sm:col-span-1" />
5454
<CardDetailsProperty Label="RPID" Value="@cred.RPID" class="sm:col-span-1" />
5555
<CardDetailsProperty Label="Origin" Value="@cred.Origin" class="sm:col-span-1" />
56-
<CardDetailsProperty Label="Authenticator" Value="@(cred.AuthenticatorName ?? "<unknown>")" class="sm:col-span-1" />
57-
<CardDetailsProperty Label="AaGuid" Value="@cred.AaGuid" class="sm:col-span-1" />
56+
<CardDetailsProperty Label="AaGuid" Value="@cred.AaGuid" class="sm:col-span-2" />
5857
<CardDetailsProperty Label="Discoverable" Value="@(cred.IsDiscoverable.HasValue ? cred.IsDiscoverable.Value : "Unknown")" class="sm:col-span-1" />
5958
<CardDetailsProperty Label="Backup State / Synced" Value="@(cred.BackupState.HasValue ? cred.BackupState.Value : "Unknown")" class="sm:col-span-1" />
6059
<CardDetailsProperty Label="Backup Eligibility" Value="@(cred.IsBackupEligible.HasValue ? cred.IsBackupEligible.Value : "Unknown")" class="sm:col-span-1" />

src/AdminConsole/Components/Shared/Credentials.razor.cs

Lines changed: 69 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,31 @@ public partial class Credentials : ComponentBase
1010
{
1111
public const string ManageCredentialFormName = "manage-credential-form";
1212

13-
public required IReadOnlyCollection<Credential>? Items { get; set; }
14-
15-
public IReadOnlyCollection<CredentialModel> GetItems() =>
16-
Items?.Select(x => new CredentialModel(
17-
x.Descriptor.Id,
18-
x.PublicKey,
19-
x.SignatureCounter,
20-
x.AttestationFmt,
21-
x.CreatedAt,
22-
x.AaGuid,
23-
x.LastUsedAt,
24-
x.RpId,
25-
x.Origin,
26-
x.Device,
27-
x.Nickname,
28-
x.BackupState,
29-
x.IsBackupEligible,
30-
x.IsDiscoverable,
31-
x.AuthenticatorDisplayName ?? AuthenticatorDataProvider.GetName(x.AaGuid))
32-
).ToArray() ?? [];
13+
public required IReadOnlyCollection<Credential> Items { get; set; }
14+
15+
public IReadOnlyCollection<CredentialModel> GetItems()
16+
{
17+
return Items.Select(x =>
18+
{
19+
var viewModel = new CredentialModel(
20+
x.Descriptor.Id,
21+
x.PublicKey,
22+
x.SignatureCounter,
23+
x.AttestationFmt,
24+
x.CreatedAt,
25+
x.AaGuid,
26+
x.LastUsedAt,
27+
x.RpId,
28+
x.Origin,
29+
x.Device,
30+
x.Nickname,
31+
x.BackupState,
32+
x.IsBackupEligible,
33+
x.IsDiscoverable,
34+
AuthenticatorDataProvider.GetName(x.AaGuid));
35+
return viewModel;
36+
}).ToList();
37+
}
3338

3439
/// <summary>
3540
/// Determines whether the details of the credentials should be hidden.
@@ -97,7 +102,7 @@ public record CredentialModel
97102

98103
public bool? IsDiscoverable { get; }
99104

100-
public string? AuthenticatorName { get; set; }
105+
public string AuthenticatorName { get; set; }
101106

102107
public bool IsNew()
103108
{
@@ -107,18 +112,54 @@ public bool IsNew()
107112
/// <summary>
108113
/// The title of the credential card.
109114
/// </summary>
110-
public string Title => AuthenticatorName?.NullIfEmpty() ?? Device.NullIfEmpty() ?? "Passkey";
115+
public string Title
116+
{
117+
get
118+
{
119+
if (IsAuthenticatorKnown)
120+
{
121+
return AuthenticatorName;
122+
}
123+
return string.IsNullOrEmpty(Device) ? "Passkey" : Device;
124+
}
125+
}
111126

112127
private string? _subtitle;
113128

114129
/// <summary>
115-
/// The subtitle of the credential card.
130+
/// The sub title of the credential card.
116131
/// </summary>
117-
public string SubTitle => _subtitle ??= AuthenticatorName switch
132+
public string? SubTitle
118133
{
119-
null => Nickname,
120-
_ => !string.IsNullOrEmpty(Nickname) ? $"{Nickname} on {Device}" : Device
121-
};
134+
get
135+
{
136+
if (_subtitle != null)
137+
{
138+
return _subtitle;
139+
}
140+
141+
if (IsAuthenticatorKnown)
142+
{
143+
if (string.IsNullOrEmpty(Nickname))
144+
{
145+
_subtitle = Device;
146+
}
147+
else
148+
{
149+
var nickname = string.IsNullOrEmpty(Nickname) ? "No nickname" : Nickname;
150+
_subtitle = $"{nickname} on {Device}";
151+
}
152+
}
153+
else
154+
{
155+
_subtitle = Nickname;
156+
}
157+
158+
return _subtitle;
159+
}
160+
}
161+
162+
public bool IsAuthenticatorKnown => AaGuid != Guid.Empty;
122163

123164
public CredentialModel(
124165
byte[] descriptorId,
@@ -135,7 +176,7 @@ public CredentialModel(
135176
bool? backupState,
136177
bool? isBackupEligible,
137178
bool? isDiscoverable,
138-
string? authenticatorName)
179+
string authenticatorName)
139180
{
140181
DescriptorId = descriptorId.ToBase64Url();
141182
PublicKey = publicKey;

src/AdminConsole/Helpers/StringExtensions.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)