1
0
mirror of https://github.com/bitwarden/server synced 2025-12-24 20:23:21 +00:00

[PM-22503] Fix manage cipher permission (#5972)

* Added new tests to validate that the ciphers are being grouped and filtered correctly when assigned to multiple collections and changing order of grouping properties.
This commit is contained in:
Jared McCannon
2025-06-23 12:11:32 -04:00
committed by GitHub
parent cdfe51f9d6
commit d2410747d0
3 changed files with 72 additions and 3 deletions

View File

@@ -457,7 +457,7 @@ public class CipherRepository : Repository<Core.Vault.Entities.Cipher, Cipher, G
using (var scope = ServiceScopeFactory.CreateScope())
{
var dbContext = GetDatabaseContext(scope);
IQueryable<CipherDetails> cipherDetailsView = withOrganizations ?
var cipherDetailsView = withOrganizations ?
new UserCipherDetailsQuery(userId).Run(dbContext) :
new CipherDetailsQuery(userId).Run(dbContext);
if (!withOrganizations)
@@ -485,8 +485,15 @@ public class CipherRepository : Repository<Core.Vault.Entities.Cipher, Cipher, G
Key = c.Key
};
}
var ciphers = await cipherDetailsView.ToListAsync();
return ciphers;
return ciphers.GroupBy(c => c.Id)
.Select(g => g.OrderByDescending(c => c.Manage)
.ThenByDescending(c => c.Edit)
.ThenByDescending(c => c.ViewPassword)
.First())
.ToList();
}
}