diff --git a/apps/server/AliasVault.Client/Main/Components/TotpCodes/TotpCodes.razor b/apps/server/AliasVault.Client/Main/Components/TotpCodes/TotpCodes.razor
index 4a1ef1c74..a20c3d34b 100644
--- a/apps/server/AliasVault.Client/Main/Components/TotpCodes/TotpCodes.razor
+++ b/apps/server/AliasVault.Client/Main/Components/TotpCodes/TotpCodes.razor
@@ -30,27 +30,23 @@
}
- @if ((TotpCodeList.Count == 0 || TotpCodeList.All(t => t.IsDeleted)) && !IsAddFormVisible)
- {
-
- }
- else
- {
- @if (IsAddFormVisible)
+ @* Always show add form or existing codes - no empty state *@
+ @if (IsAddFormVisible)
{
@Localizer["AddTotpCodeModalTitle"]
-
+ @if (HasExistingCodes)
+ {
+
+ }
@Localizer["TotpInstructions"]
@@ -94,7 +90,6 @@
}
- }
@code {
@@ -130,6 +125,11 @@
private TotpCodeEdit NewTotpCode { get; set; } = new();
private List OriginalTotpCodeIds { get; set; } = [];
+ ///
+ /// Returns true if there are existing (non-deleted) TOTP codes.
+ ///
+ private bool HasExistingCodes => TotpCodeList.Any(t => !t.IsDeleted);
+
///
protected override async Task OnInitializedAsync()
{
diff --git a/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razor b/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razor
index dadfae66b..69afdb284 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razor
@@ -692,11 +692,12 @@ else
}
///
- /// 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.
///
private bool CanRemove2FASection()
{
- return true;
+ return Obj.TotpCodes.Any(t => !t.IsDeleted);
}
///