From 2cea391ebfa5b67410ba494edd1d3311d62f3473 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Mon, 18 Aug 2025 17:52:06 +0800 Subject: [PATCH] :bug: Fix logout session --- DysonNetwork.Pass/Account/AccountService.cs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/DysonNetwork.Pass/Account/AccountService.cs b/DysonNetwork.Pass/Account/AccountService.cs index fea2489..4618e17 100644 --- a/DysonNetwork.Pass/Account/AccountService.cs +++ b/DysonNetwork.Pass/Account/AccountService.cs @@ -449,8 +449,7 @@ public class AccountService( public async Task UpdateDeviceName(Account account, string deviceId, string label) { - var device = await db.AuthClients.FirstOrDefaultAsync( - c => c.DeviceId == deviceId && c.AccountId == account.Id + var device = await db.AuthClients.FirstOrDefaultAsync(c => c.DeviceId == deviceId && c.AccountId == account.Id ); if (device is null) throw new InvalidOperationException("Device was not found."); @@ -470,16 +469,11 @@ public class AccountService( .FirstOrDefaultAsync(); if (session is null) throw new InvalidOperationException("Session was not found."); - var sessions = await db.AuthSessions - .Include(s => s.Challenge) - .Where(s => s.AccountId == session.Id && s.Challenge.DeviceId == session.Challenge.DeviceId) - .ToListAsync(); - if (session.Challenge.ClientId.HasValue) { if (!await IsDeviceActive(session.Challenge.ClientId.Value)) await pusher.UnsubscribePushNotificationsAsync(new UnsubscribePushNotificationsRequest() - { DeviceId = session.Challenge.Client!.DeviceId } + { DeviceId = session.Challenge.Client!.DeviceId } ); } @@ -489,14 +483,12 @@ public class AccountService( .Where(s => s.Challenge.DeviceId == session.Challenge.DeviceId) .ExecuteDeleteAsync(); - foreach (var item in sessions) - await cache.RemoveAsync($"{AuthService.AuthCachePrefix}{item.Id}"); + await cache.RemoveAsync($"{AuthService.AuthCachePrefix}{session.Id}"); } public async Task DeleteDevice(Account account, string deviceId) { - var device = await db.AuthClients.FirstOrDefaultAsync( - c => c.DeviceId == deviceId && c.AccountId == account.Id + var device = await db.AuthClients.FirstOrDefaultAsync(c => c.DeviceId == deviceId && c.AccountId == account.Id ); if (device is null) throw new InvalidOperationException("Device not found."); @@ -689,4 +681,4 @@ public class AccountService( await db.BulkInsertAsync(newProfiles); } } -} +} \ No newline at end of file