From bb7c9ca9d8d703ac7000bf7f5e264afba8634b09 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 6 Jun 2025 01:00:22 +0800 Subject: [PATCH] :bug: Yeah, another bug fix --- DysonNetwork.Sphere/Account/AccountService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/DysonNetwork.Sphere/Account/AccountService.cs b/DysonNetwork.Sphere/Account/AccountService.cs index 5db8755..d9abc11 100644 --- a/DysonNetwork.Sphere/Account/AccountService.cs +++ b/DysonNetwork.Sphere/Account/AccountService.cs @@ -169,7 +169,7 @@ public class AccountService( if (factor.EnabledAt is null) throw new ArgumentException("The factor has been disabled."); var count = await db.AccountAuthFactors - .Where(f => f.AccountId == factor.Id && f.EnabledAt != null) + .Where(f => f.AccountId == factor.AccountId && f.EnabledAt != null) .CountAsync(); if (count <= 1) throw new InvalidOperationException( @@ -182,7 +182,8 @@ public class AccountService( public async Task DeleteAuthFactor(AccountAuthFactor factor) { var count = await db.AccountAuthFactors - .Where(f => f.AccountId == factor.Id) + .Where(f => f.AccountId == factor.AccountId) + .If(factor.EnabledAt is not null, q => q.Where(f => f.EnabledAt != null)) .CountAsync(); if (count <= 1) throw new InvalidOperationException("Deleting this auth factor will cause you have no auth factor.");