mirror of
https://github.com/bitwarden/server.git
synced 2024-12-24 17:17:40 +01:00
filter status
This commit is contained in:
parent
1158e7051d
commit
da29160218
@ -160,7 +160,8 @@ namespace Bit.Api.Controllers
|
|||||||
public async Task<ProfileResponseModel> GetProfile()
|
public async Task<ProfileResponseModel> GetProfile()
|
||||||
{
|
{
|
||||||
var user = await _userService.GetUserByPrincipalAsync(User);
|
var user = await _userService.GetUserByPrincipalAsync(User);
|
||||||
var organizationUserDetails = await _organizationUserRepository.GetManyDetailsByUserAsync(user.Id);
|
var organizationUserDetails = await _organizationUserRepository.GetManyDetailsByUserAsync(user.Id,
|
||||||
|
OrganizationUserStatusType.Confirmed);
|
||||||
var response = new ProfileResponseModel(user, organizationUserDetails);
|
var response = new ProfileResponseModel(user, organizationUserDetails);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@ -169,7 +170,8 @@ namespace Bit.Api.Controllers
|
|||||||
public async Task<ListResponseModel<ProfileOrganizationResponseModel>> GetOrganizations()
|
public async Task<ListResponseModel<ProfileOrganizationResponseModel>> GetOrganizations()
|
||||||
{
|
{
|
||||||
var userId = _userService.GetProperUserId(User);
|
var userId = _userService.GetProperUserId(User);
|
||||||
var organizationUserDetails = await _organizationUserRepository.GetManyDetailsByUserAsync(userId.Value);
|
var organizationUserDetails = await _organizationUserRepository.GetManyDetailsByUserAsync(userId.Value,
|
||||||
|
OrganizationUserStatusType.Confirmed);
|
||||||
var responseData = organizationUserDetails.Select(o => new ProfileOrganizationResponseModel(o));
|
var responseData = organizationUserDetails.Select(o => new ProfileOrganizationResponseModel(o));
|
||||||
return new ListResponseModel<ProfileOrganizationResponseModel>(responseData);
|
return new ListResponseModel<ProfileOrganizationResponseModel>(responseData);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Bit.Core.Models.Table;
|
using Bit.Core.Models.Table;
|
||||||
using Bit.Core.Models.Data;
|
using Bit.Core.Models.Data;
|
||||||
|
using Bit.Core.Enums;
|
||||||
|
|
||||||
namespace Bit.Core.Repositories
|
namespace Bit.Core.Repositories
|
||||||
{
|
{
|
||||||
@ -11,6 +12,7 @@ namespace Bit.Core.Repositories
|
|||||||
Task<OrganizationUser> GetByOrganizationAsync(Guid organizationId, Guid userId);
|
Task<OrganizationUser> GetByOrganizationAsync(Guid organizationId, Guid userId);
|
||||||
Task<Tuple<OrganizationUserUserDetails, ICollection<SubvaultUserDetails>>> GetDetailsByIdAsync(Guid id);
|
Task<Tuple<OrganizationUserUserDetails, ICollection<SubvaultUserDetails>>> GetDetailsByIdAsync(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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using Dapper;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Bit.Core.Models.Data;
|
using Bit.Core.Models.Data;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Bit.Core.Enums;
|
||||||
|
|
||||||
namespace Bit.Core.Repositories.SqlServer
|
namespace Bit.Core.Repositories.SqlServer
|
||||||
{
|
{
|
||||||
@ -61,13 +62,14 @@ namespace Bit.Core.Repositories.SqlServer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ICollection<OrganizationUserOrganizationDetails>> GetManyDetailsByUserAsync(Guid userId)
|
public async Task<ICollection<OrganizationUserOrganizationDetails>> GetManyDetailsByUserAsync(Guid userId,
|
||||||
|
OrganizationUserStatusType? status = null)
|
||||||
{
|
{
|
||||||
using(var connection = new SqlConnection(ConnectionString))
|
using(var connection = new SqlConnection(ConnectionString))
|
||||||
{
|
{
|
||||||
var results = await connection.QueryAsync<OrganizationUserOrganizationDetails>(
|
var results = await connection.QueryAsync<OrganizationUserOrganizationDetails>(
|
||||||
"[dbo].[OrganizationUserOrganizationDetails_ReadByUserId]",
|
"[dbo].[OrganizationUserOrganizationDetails_ReadByUserIdStatus]",
|
||||||
new { UserId = userId },
|
new { UserId = userId, Status = status },
|
||||||
commandType: CommandType.StoredProcedure);
|
commandType: CommandType.StoredProcedure);
|
||||||
|
|
||||||
return results.ToList();
|
return results.ToList();
|
||||||
|
@ -168,7 +168,7 @@
|
|||||||
<Build Include="dbo\Stored Procedures\Grant_Save.sql" />
|
<Build Include="dbo\Stored Procedures\Grant_Save.sql" />
|
||||||
<Build Include="dbo\Stored Procedures\User_ReadAccountRevisionDateById.sql" />
|
<Build Include="dbo\Stored Procedures\User_ReadAccountRevisionDateById.sql" />
|
||||||
<Build Include="dbo\Stored Procedures\User_ReadPublicKeyById.sql" />
|
<Build Include="dbo\Stored Procedures\User_ReadPublicKeyById.sql" />
|
||||||
<Build Include="dbo\Stored Procedures\OrganizationUserOrganizationDetails_ReadByUserId.sql" />
|
<Build Include="dbo\Stored Procedures\OrganizationUserOrganizationDetails_ReadByUserIdStatus.sql" />
|
||||||
<Build Include="dbo\Stored Procedures\OrganizationUserUserDetails_ReadById.sql" />
|
<Build Include="dbo\Stored Procedures\OrganizationUserUserDetails_ReadById.sql" />
|
||||||
<Build Include="dbo\Stored Procedures\OrganizationUserUserDetails_ReadByOrganizationId.sql" />
|
<Build Include="dbo\Stored Procedures\OrganizationUserUserDetails_ReadByOrganizationId.sql" />
|
||||||
<Build Include="dbo\Stored Procedures\Subvault_ReadByOrganizationIdAdminUserId.sql" />
|
<Build Include="dbo\Stored Procedures\Subvault_ReadByOrganizationIdAdminUserId.sql" />
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
CREATE PROCEDURE [dbo].[OrganizationUserOrganizationDetails_ReadByUserId]
|
CREATE PROCEDURE [dbo].[OrganizationUserOrganizationDetails_ReadByUserIdStatus]
|
||||||
@UserId UNIQUEIDENTIFIER
|
@UserId UNIQUEIDENTIFIER,
|
||||||
|
@Status TINYINT
|
||||||
AS
|
AS
|
||||||
BEGIN
|
BEGIN
|
||||||
SET NOCOUNT ON
|
SET NOCOUNT ON
|
||||||
@ -10,4 +11,5 @@ BEGIN
|
|||||||
[dbo].[OrganizationUserOrganizationDetailsView]
|
[dbo].[OrganizationUserOrganizationDetailsView]
|
||||||
WHERE
|
WHERE
|
||||||
[UserId] = @UserId
|
[UserId] = @UserId
|
||||||
|
AND (@Status IS NULL OR [Status] = @Status)
|
||||||
END
|
END
|
Loading…
Reference in New Issue
Block a user