From a0b7781e66c1debd3de1ed2d8fb92a1a144ebec2 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Wed, 25 Aug 2021 11:02:37 -0500 Subject: [PATCH] properly unban accounts associated with IP with toggle --- SharedLibraryCore/Services/ClientService.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/SharedLibraryCore/Services/ClientService.cs b/SharedLibraryCore/Services/ClientService.cs index 7cb374fe..a0ad18cb 100644 --- a/SharedLibraryCore/Services/ClientService.cs +++ b/SharedLibraryCore/Services/ClientService.cs @@ -394,9 +394,19 @@ namespace SharedLibraryCore.Services var iqMatchingClients = ctx.Clients .Where(_client => _client.AliasLinkId == entity.AliasLinkId); + var iqLinkClients = new List().AsQueryable(); + if (!_appConfig.EnableImplicitAccountLinking) + { + var linkIds = await ctx.Aliases.Where(alias => + alias.IPAddress != null && alias.IPAddress == temporalClient.IPAddress) + .Select(alias => alias.LinkId) + .ToListAsync(); + iqLinkClients = ctx.Clients.Where(client => linkIds.Contains(client.AliasLinkId)); + } + // this updates the level for all the clients with the same LinkId // only if their new level is flagged or banned - await iqMatchingClients.ForEachAsync(_client => + await iqMatchingClients.Union(iqLinkClients).ForEachAsync(_client => { _client.Level = newPermission; _logger.LogInformation("Updated linked {clientId} to {newPermission}", _client.ClientId,