Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ else

<form @formname="add-passkey" @onsubmit="AddPasskey" method="post">
<AntiforgeryToken />
<PasskeySubmit Operation="PasskeyOperation.Create" Name="Input" class="btn btn-primary">Add a new passkey</PasskeySubmit>
@if (currentPasskeys is not { Count: >= MaxPasskeyCount })
{
<PasskeySubmit Operation="PasskeyOperation.Create" Name="Input" class="btn btn-primary">Add a new passkey</PasskeySubmit>
}
</form>

@code {
private const int MaxPasskeyCount = 100;

private ApplicationUser? user;
private IList<UserPasskeyInfo>? currentPasskeys;

Expand Down Expand Up @@ -100,6 +105,12 @@ else
return;
}

if (currentPasskeys!.Count >= MaxPasskeyCount)
{
RedirectManager.RedirectToCurrentPageWithStatus($"Error: You have reached the maximum number of allowed passkeys.", HttpContext);
return;
}

var attestationResult = await SignInManager.PerformPasskeyAttestationAsync(Input.CredentialJson);
if (!attestationResult.Succeeded)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
private sealed class InputModel
{
[Required]
[StringLength(200, ErrorMessage = "Passkey names must be no longer than {1} characters.")]
public string Name { get; set; } = "";
}
}
Loading