mirror of
https://github.com/bitwarden/server.git
synced 2025-04-17 11:08:16 -05:00
apis for getting user details
This commit is contained in:
parent
df09b02ecc
commit
00f3c476ae
@ -17,6 +17,9 @@ namespace Bit.Core.Repositories
|
|||||||
Task<int> GetCountByOrganizationAsync(Guid organizationId, string email, bool onlyRegisteredUsers);
|
Task<int> GetCountByOrganizationAsync(Guid organizationId, string email, bool onlyRegisteredUsers);
|
||||||
Task<OrganizationUser> GetByOrganizationAsync(Guid organizationId, Guid userId);
|
Task<OrganizationUser> GetByOrganizationAsync(Guid organizationId, Guid userId);
|
||||||
Task<Tuple<OrganizationUser, ICollection<SelectionReadOnly>>> GetByIdWithCollectionsAsync(Guid id);
|
Task<Tuple<OrganizationUser, ICollection<SelectionReadOnly>>> GetByIdWithCollectionsAsync(Guid id);
|
||||||
|
Task<OrganizationUserUserDetails> GetDetailsByIdAsync(Guid id);
|
||||||
|
Task<Tuple<OrganizationUserUserDetails, ICollection<SelectionReadOnly>>>
|
||||||
|
GetDetailsByIdWithCollectionsAsync(Guid id);
|
||||||
Task<ICollection<OrganizationUserUserDetails>> GetManyDetailsByOrganizationAsync(Guid organizationId);
|
Task<ICollection<OrganizationUserUserDetails>> GetManyDetailsByOrganizationAsync(Guid organizationId);
|
||||||
Task<ICollection<OrganizationUserOrganizationDetails>> GetManyDetailsByUserAsync(Guid userId,
|
Task<ICollection<OrganizationUserOrganizationDetails>> GetManyDetailsByUserAsync(Guid userId,
|
||||||
OrganizationUserStatusType? status = null);
|
OrganizationUserStatusType? status = null);
|
||||||
|
@ -130,6 +130,34 @@ namespace Bit.Core.Repositories.SqlServer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<OrganizationUserUserDetails> GetDetailsByIdAsync(Guid id)
|
||||||
|
{
|
||||||
|
using(var connection = new SqlConnection(ConnectionString))
|
||||||
|
{
|
||||||
|
var results = await connection.QueryAsync<OrganizationUserUserDetails>(
|
||||||
|
"[dbo].[OrganizationUserUserDetails_ReadById]",
|
||||||
|
new { Id = id },
|
||||||
|
commandType: CommandType.StoredProcedure);
|
||||||
|
|
||||||
|
return results.SingleOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public async Task<Tuple<OrganizationUserUserDetails, ICollection<SelectionReadOnly>>>
|
||||||
|
GetDetailsByIdWithCollectionsAsync(Guid id)
|
||||||
|
{
|
||||||
|
using(var connection = new SqlConnection(ConnectionString))
|
||||||
|
{
|
||||||
|
var results = await connection.QueryMultipleAsync(
|
||||||
|
"[dbo].[OrganizationUserUserDetails_ReadWithCollectionsById]",
|
||||||
|
new { Id = id },
|
||||||
|
commandType: CommandType.StoredProcedure);
|
||||||
|
|
||||||
|
var user = (await results.ReadAsync<OrganizationUserUserDetails>()).SingleOrDefault();
|
||||||
|
var collections = (await results.ReadAsync<SelectionReadOnly>()).ToList();
|
||||||
|
return new Tuple<OrganizationUserUserDetails, ICollection<SelectionReadOnly>>(user, collections);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<ICollection<OrganizationUserUserDetails>> GetManyDetailsByOrganizationAsync(Guid organizationId)
|
public async Task<ICollection<OrganizationUserUserDetails>> GetManyDetailsByOrganizationAsync(Guid organizationId)
|
||||||
{
|
{
|
||||||
using(var connection = new SqlConnection(ConnectionString))
|
using(var connection = new SqlConnection(ConnectionString))
|
||||||
|
@ -248,5 +248,7 @@
|
|||||||
<Build Include="dbo\Views\TransactionView.sql" />
|
<Build Include="dbo\Views\TransactionView.sql" />
|
||||||
<Build Include="dbo\Stored Procedures\Transaction_ReadByUserId.sql" />
|
<Build Include="dbo\Stored Procedures\Transaction_ReadByUserId.sql" />
|
||||||
<Build Include="dbo\Stored Procedures\Transaction_ReadByGatewayId.sql" />
|
<Build Include="dbo\Stored Procedures\Transaction_ReadByGatewayId.sql" />
|
||||||
|
<Build Include="dbo\Stored Procedures\OrganizationUserUserDetails_ReadById.sql" />
|
||||||
|
<Build Include="dbo\Stored Procedures\OrganizationUserUserDetails_ReadWithCollectionsById.sql" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -0,0 +1,13 @@
|
|||||||
|
CREATE PROCEDURE [dbo].[OrganizationUserUserDetails_ReadById]
|
||||||
|
@Id UNIQUEIDENTIFIER
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
SET NOCOUNT ON
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
[dbo].[OrganizationUserUserDetailsView]
|
||||||
|
WHERE
|
||||||
|
[Id] = @Id
|
||||||
|
END
|
@ -0,0 +1,18 @@
|
|||||||
|
CREATE PROCEDURE [dbo].[OrganizationUserUserDetails_ReadWithCollectionsById]
|
||||||
|
@Id UNIQUEIDENTIFIER
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
SET NOCOUNT ON
|
||||||
|
|
||||||
|
EXEC [OrganizationUserUserDetails_ReadById] @Id
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
CU.[CollectionId] Id,
|
||||||
|
CU.[ReadOnly]
|
||||||
|
FROM
|
||||||
|
[dbo].[OrganizationUser] OU
|
||||||
|
INNER JOIN
|
||||||
|
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[OrganizationUserId] = [OU].[Id]
|
||||||
|
WHERE
|
||||||
|
[OrganizationUserId] = @Id
|
||||||
|
END
|
@ -337,3 +337,50 @@ FROM
|
|||||||
INNER JOIN
|
INNER JOIN
|
||||||
[dbo].[Organization] O ON O.[Id] = OU.[OrganizationId]
|
[dbo].[Organization] O ON O.[Id] = OU.[OrganizationId]
|
||||||
GO
|
GO
|
||||||
|
|
||||||
|
IF OBJECT_ID('[dbo].[OrganizationUserUserDetails_ReadById]') IS NOT NULL
|
||||||
|
BEGIN
|
||||||
|
DROP PROCEDURE [dbo].[OrganizationUserUserDetails_ReadById]
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE PROCEDURE [dbo].[OrganizationUserUserDetails_ReadById]
|
||||||
|
@Id UNIQUEIDENTIFIER
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
SET NOCOUNT ON
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
[dbo].[OrganizationUserUserDetailsView]
|
||||||
|
WHERE
|
||||||
|
[Id] = @Id
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
IF OBJECT_ID('[dbo].[OrganizationUserUserDetails_ReadWithCollectionsById]') IS NOT NULL
|
||||||
|
BEGIN
|
||||||
|
DROP PROCEDURE [dbo].[OrganizationUserUserDetails_ReadWithCollectionsById]
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE PROCEDURE [dbo].[OrganizationUserUserDetails_ReadWithCollectionsById]
|
||||||
|
@Id UNIQUEIDENTIFIER
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
SET NOCOUNT ON
|
||||||
|
|
||||||
|
EXEC [OrganizationUserUserDetails_ReadById] @Id
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
CU.[CollectionId] Id,
|
||||||
|
CU.[ReadOnly]
|
||||||
|
FROM
|
||||||
|
[dbo].[OrganizationUser] OU
|
||||||
|
INNER JOIN
|
||||||
|
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[OrganizationUserId] = [OU].[Id]
|
||||||
|
WHERE
|
||||||
|
[OrganizationUserId] = @Id
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
Loading…
x
Reference in New Issue
Block a user