From 06e0f3b73e3d8f05f14849da4d0d8a1e9c6c6d58 Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Tue, 20 Jul 2021 11:46:30 +1000 Subject: [PATCH] Return collection with highest permission levels --- .../SqlServer/CollectionRepository.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Core/Repositories/SqlServer/CollectionRepository.cs b/src/Core/Repositories/SqlServer/CollectionRepository.cs index e774dbaec..c80c191db 100644 --- a/src/Core/Repositories/SqlServer/CollectionRepository.cs +++ b/src/Core/Repositories/SqlServer/CollectionRepository.cs @@ -107,7 +107,21 @@ namespace Bit.Core.Repositories.SqlServer // Return distinct Id results. return results .GroupBy(c => c.Id) - .Select(c => c.First()) + .Select(grouping => + { + var first = grouping.First(); + if (first.HidePasswords) + { + first.HidePasswords = !grouping.Any(c => !c.HidePasswords); + } + + if (first.ReadOnly) + { + first.ReadOnly = !grouping.Any(c => !c.ReadOnly); + } + + return first; + }) .ToList(); } }