mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-02-02 18:33:21 -05:00
Tweak TOTP add flow (#1404)
This commit is contained in:
@@ -30,27 +30,23 @@
|
||||
</button>
|
||||
}
|
||||
|
||||
@if ((TotpCodeList.Count == 0 || TotpCodeList.All(t => t.IsDeleted)) && !IsAddFormVisible)
|
||||
{
|
||||
<div class="flex flex-col justify-center">
|
||||
<p class="text-gray-500 dark:text-gray-400"><a @onclick="ShowAddForm" id="add-totp-code" href="javascript:void(0)" class="text-blue-600 hover:text-blue-800 dark:text-blue-500 dark:hover:text-blue-400">@Localizer["AddTotpCodeDescription"]</a></p>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (IsAddFormVisible)
|
||||
@* Always show add form or existing codes - no empty state *@
|
||||
@if (IsAddFormVisible)
|
||||
{
|
||||
<div class="p-4 mb-4 bg-gray-50 border border-gray-200 rounded-lg dark:bg-gray-700 dark:border-gray-600">
|
||||
<EditForm Model="@NewTotpCode" OnValidSubmit="AddTotpCode">
|
||||
<DataAnnotationsValidator />
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h4 class="text-lg font-medium text-gray-900 dark:text-white">@Localizer["AddTotpCodeModalTitle"]</h4>
|
||||
<button @onclick="HideAddForm" type="button" class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white">
|
||||
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
|
||||
</svg>
|
||||
<span class="sr-only">@Localizer["CloseFormButton"]</span>
|
||||
</button>
|
||||
@if (HasExistingCodes)
|
||||
{
|
||||
<button @onclick="HideAddForm" type="button" class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white">
|
||||
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
|
||||
</svg>
|
||||
<span class="sr-only">@Localizer["CloseFormButton"]</span>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
<p class="mb-4 text-sm text-gray-500 dark:text-gray-400">@Localizer["TotpInstructions"]</p>
|
||||
<div class="mb-4">
|
||||
@@ -94,7 +90,6 @@
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
@@ -130,6 +125,11 @@
|
||||
private TotpCodeEdit NewTotpCode { get; set; } = new();
|
||||
private List<Guid> OriginalTotpCodeIds { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if there are existing (non-deleted) TOTP codes.
|
||||
/// </summary>
|
||||
private bool HasExistingCodes => TotpCodeList.Any(t => !t.IsDeleted);
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
|
||||
@@ -692,11 +692,12 @@ else
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the 2FA section can be removed (always true when visible).
|
||||
/// Checks if the 2FA section can be removed.
|
||||
/// Only allow removal when there's at least one TOTP code registered.
|
||||
/// </summary>
|
||||
private bool CanRemove2FASection()
|
||||
{
|
||||
return true;
|
||||
return Obj.TotpCodes.Any(t => !t.IsDeleted);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user