mirror of
https://github.com/bitwarden/server.git
synced 2025-04-12 00:28:11 -05:00
feat(EF WebAuthnCreds Repo): [Auth/PM-19629] EF WebAuthnCredentialRepository.cs - Rewrite query to avoid reading entire table into memory (#5567)
This commit is contained in:
parent
786b0edceb
commit
683ade9ffc
@ -68,12 +68,11 @@ public class WebAuthnCredentialRepository : Repository<Core.Auth.Entities.WebAut
|
|||||||
var newCreds = credentials.ToList();
|
var newCreds = credentials.ToList();
|
||||||
using var scope = ServiceScopeFactory.CreateScope();
|
using var scope = ServiceScopeFactory.CreateScope();
|
||||||
var dbContext = GetDatabaseContext(scope);
|
var dbContext = GetDatabaseContext(scope);
|
||||||
var userWebauthnCredentials = await GetDbSet(dbContext)
|
|
||||||
.Where(wc => wc.Id == wc.Id)
|
var newCredIds = newCreds.Select(nwc => nwc.Id).ToList();
|
||||||
|
var validUserWebauthnCredentials = await GetDbSet(dbContext)
|
||||||
|
.Where(wc => wc.UserId == userId && newCredIds.Contains(wc.Id))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
var validUserWebauthnCredentials = userWebauthnCredentials
|
|
||||||
.Where(wc => newCreds.Any(nwc => nwc.Id == wc.Id))
|
|
||||||
.Where(wc => wc.UserId == userId);
|
|
||||||
|
|
||||||
foreach (var wc in validUserWebauthnCredentials)
|
foreach (var wc in validUserWebauthnCredentials)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user