mirror of
https://github.com/bitwarden/server.git
synced 2025-07-16 23:27:30 -05:00
manager group user apis
This commit is contained in:
@ -174,7 +174,6 @@
|
||||
<Build Include="dbo\Stored Procedures\GroupUser_ReadGroupIdsByOrganizationUserId.sql" />
|
||||
<Build Include="dbo\Stored Procedures\GroupUser_UpdateGroups.sql" />
|
||||
<Build Include="dbo\Stored Procedures\GroupUser_UpdateUsers.sql" />
|
||||
<Build Include="dbo\Stored Procedures\GroupUserDetails_ReadByGroupId.sql" />
|
||||
<Build Include="dbo\Stored Procedures\OrganizationUser_CreateWithCollections.sql" />
|
||||
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadWithCollectionsById.sql" />
|
||||
<Build Include="dbo\Stored Procedures\OrganizationUser_UpdateWithCollections.sql" />
|
||||
@ -237,5 +236,6 @@
|
||||
<Build Include="dbo\Stored Procedures\Collection_ReadWithGroupsByIdUserId.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Collection_CreateWithGroups.sql" />
|
||||
<Build Include="dbo\Stored Procedures\CollectionUser_UpdateUsers.sql" />
|
||||
<Build Include="dbo\Stored Procedures\GroupUser_ReadOrganizationUserIdsByGroupId.sql" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,11 +1,18 @@
|
||||
CREATE PROCEDURE [dbo].[CollectionUser_UpdateUsers]
|
||||
@Id UNIQUEIDENTIFIER,
|
||||
@CollectionId UNIQUEIDENTIFIER,
|
||||
@Users AS [dbo].[SelectionReadOnlyArray] READONLY
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
DECLARE @OrganizationId UNIQUEIDENTIFIER = (SELECT [OrganizationId] FROM [dbo].[Collection] WHERE [Id] = @Id)
|
||||
DECLARE @OrgId UNIQUEIDENTIFIER = (
|
||||
SELECT TOP 1
|
||||
[OrganizationId]
|
||||
FROM
|
||||
[dbo].[Collection]
|
||||
WHERE
|
||||
[Id] = @CollectionId
|
||||
)
|
||||
|
||||
;WITH [AvailableUsersCTE] AS(
|
||||
SELECT
|
||||
@ -13,29 +20,29 @@ BEGIN
|
||||
FROM
|
||||
[dbo].[OrganizationUser]
|
||||
WHERE
|
||||
OrganizationId = @OrganizationId
|
||||
OrganizationId = @OrgId
|
||||
)
|
||||
MERGE
|
||||
[dbo].[CollectionUser] AS [Target]
|
||||
USING
|
||||
@Users AS [Source]
|
||||
ON
|
||||
[Target].[CollectionId] = @Id
|
||||
[Target].[CollectionId] = @CollectionId
|
||||
AND [Target].[OrganizationUserId] = [Source].[Id]
|
||||
WHEN NOT MATCHED BY TARGET
|
||||
AND [Source].[Id] IN (SELECT [Id] FROM [AvailableUsersCTE]) THEN
|
||||
INSERT VALUES
|
||||
(
|
||||
@Id,
|
||||
@CollectionId,
|
||||
[Source].[Id],
|
||||
[Source].[ReadOnly]
|
||||
)
|
||||
WHEN MATCHED AND [Target].[ReadOnly] != [Source].[ReadOnly] THEN
|
||||
UPDATE SET [Target].[ReadOnly] = [Source].[ReadOnly]
|
||||
WHEN NOT MATCHED BY SOURCE
|
||||
AND [Target].[CollectionId] = @Id THEN
|
||||
AND [Target].[CollectionId] = @CollectionId THEN
|
||||
DELETE
|
||||
;
|
||||
|
||||
EXEC [dbo].[User_BumpAccountRevisionDateByCollectionId] @Id, @OrganizationId
|
||||
EXEC [dbo].[User_BumpAccountRevisionDateByCollectionId] @CollectionId, @OrgId
|
||||
END
|
@ -1,22 +0,0 @@
|
||||
CREATE PROCEDURE [dbo].[GroupUserDetails_ReadByGroupId]
|
||||
@GroupId UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SELECT
|
||||
OU.[Id] AS [OrganizationUserId],
|
||||
OU.[AccessAll],
|
||||
U.[Name],
|
||||
ISNULL(U.[Email], OU.[Email]) Email,
|
||||
OU.[Status],
|
||||
OU.[Type]
|
||||
FROM
|
||||
[dbo].[OrganizationUser] OU
|
||||
INNER JOIN
|
||||
[dbo].[GroupUser] GU ON GU.[OrganizationUserId] = OU.[Id]
|
||||
LEFT JOIN
|
||||
[dbo].[User] U ON U.[Id] = OU.[UserId]
|
||||
WHERE
|
||||
GU.[GroupId] = @GroupId
|
||||
END
|
@ -0,0 +1,13 @@
|
||||
CREATE PROCEDURE [dbo].[GroupUser_ReadOrganizationUserIdsByGroupId]
|
||||
@GroupId UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SELECT
|
||||
[OrganizationUserId]
|
||||
FROM
|
||||
[dbo].[GroupUser]
|
||||
WHERE
|
||||
[GroupId] = @GroupId
|
||||
END
|
Reference in New Issue
Block a user