1
0
mirror of https://github.com/bitwarden/server synced 2026-01-01 16:13:33 +00:00

fix type error in UserCipherDetailsQuery

This commit is contained in:
jaasen-livefront
2025-11-17 15:01:12 -08:00
parent 933e199581
commit 53ea531891
3 changed files with 52 additions and 49 deletions

View File

@@ -23,7 +23,7 @@ public class UserCipherDetailsQuery : IQuery<CipherDetails>
throw new InvalidOperationException("UserCipherDetailsQuery requires a non-null userId.");
}
var userId = _userId;
var userId = _userId.Value;
var query = from c in dbContext.Ciphers
join ou in dbContext.OrganizationUsers
@@ -64,8 +64,8 @@ public class UserCipherDetailsQuery : IQuery<CipherDetails>
from cg in cg_g.DefaultIfEmpty()
from ca in caGroup.DefaultIfEmpty()
where (cu == null ? (Guid?)null : cu.CollectionId) != null || (cg == null ? (Guid?)null : cg.CollectionId) != null
where (cu == null ? (Guid?)null : cu.CollectionId) != null
|| (cg == null ? (Guid?)null : cg.CollectionId) != null
select new
{
@@ -93,10 +93,11 @@ public class UserCipherDetailsQuery : IQuery<CipherDetails>
where c.UserId == _userId
join ca in dbContext.CipherArchives
on new { CipherId = c.Id, UserId = userId }
equals new { Id = ca.CipherId, userId = ca.UserId }
on c.Id equals ca.CipherId
into caGroup
from ca in caGroup.DefaultIfEmpty()
from ca in caGroup
.Where(a => a.UserId == userId)
.DefaultIfEmpty()
select new
{

View File

@@ -24,16 +24,16 @@ SELECT
C.FolderId,
C.DeletedDate,
C.Reprompt,
C.Key,
C.[Key],
CASE
WHEN COALESCE(CU.[ReadOnly], CG.[ReadOnly], 0) = 0
THEN 1
ELSE 0
END [Edit],
CASE
WHEN COALESCE(CU.[HidePasswords], CG.[HidePasswords], 0) = 0
THEN 1
ELSE 0
WHEN COALESCE(CU.[HidePasswords], CG.[HidePasswords], 0) = 0
THEN 1
ELSE 0
END [ViewPassword],
CASE
WHEN COALESCE(CU.[Manage], CG.[Manage], 0) = 1
@@ -80,7 +80,7 @@ SELECT
C.FolderId,
C.DeletedDate,
C.Reprompt,
C.Key,
C.[Key],
1 [Edit],
1 [ViewPassword],
1 [Manage],
@@ -88,4 +88,4 @@ SELECT
FROM
[dbo].[CipherDetails](@UserId) AS C
WHERE
C.[UserId] = @UserId
C.[UserId] = @UserId;

View File

@@ -3,45 +3,47 @@
@UserId UNIQUEIDENTIFIER
AS
BEGIN
SET NOCOUNT ON
SET NOCOUNT ON;
SELECT
[Id],
[UserId],
[OrganizationId],
[Type],
[Data],
[Attachments],
[CreationDate],
[RevisionDate],
[Favorite],
[FolderId],
[DeletedDate],
[Reprompt],
[Key],
[OrganizationUseTotp],
[ArchivedDate],
MAX ([Edit]) AS [Edit],
MAX ([ViewPassword]) AS [ViewPassword],
MAX ([Manage]) AS [Manage]
SELECT
ucd.Id,
ucd.UserId,
ucd.OrganizationId,
ucd.Type,
ucd.Data,
ucd.Attachments,
ucd.CreationDate,
ucd.RevisionDate,
ucd.Favorite,
ucd.FolderId,
ucd.DeletedDate,
ucd.Reprompt,
ucd.[Key],
ucd.OrganizationUseTotp,
MAX(ca.ArchivedDate) AS ArchivedDate,
MAX(ucd.Edit) AS Edit,
MAX(ucd.ViewPassword) AS ViewPassword,
MAX(ucd.Manage) AS Manage
FROM
[dbo].[UserCipherDetails](@UserId)
[dbo].[UserCipherDetails](@UserId) AS ucd
LEFT JOIN [dbo].[CipherArchive] AS ca
ON ca.CipherId = ucd.Id
AND ca.UserId = @UserId
WHERE
[Id] = @Id
ucd.Id = @Id
GROUP BY
[Id],
[UserId],
[OrganizationId],
[Type],
[Data],
[Attachments],
[CreationDate],
[RevisionDate],
[Favorite],
[FolderId],
[DeletedDate],
[Reprompt],
[Key],
[OrganizationUseTotp],
[ArchivedDate]
ucd.Id,
ucd.UserId,
ucd.OrganizationId,
ucd.Type,
ucd.Data,
ucd.Attachments,
ucd.CreationDate,
ucd.RevisionDate,
ucd.Favorite,
ucd.FolderId,
ucd.DeletedDate,
ucd.Reprompt,
ucd.[Key],
ucd.OrganizationUseTotp;
END