diff --git a/src/Api/Controllers/AccountsController.cs b/src/Api/Controllers/AccountsController.cs index 133f61611f..e8b6d9559d 100644 --- a/src/Api/Controllers/AccountsController.cs +++ b/src/Api/Controllers/AccountsController.cs @@ -160,7 +160,8 @@ namespace Bit.Api.Controllers public async Task GetProfile() { 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); return response; } @@ -169,7 +170,8 @@ namespace Bit.Api.Controllers public async Task> GetOrganizations() { 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)); return new ListResponseModel(responseData); } diff --git a/src/Core/Repositories/IOrganizationUserRepository.cs b/src/Core/Repositories/IOrganizationUserRepository.cs index b117d437f1..9601a5ffd7 100644 --- a/src/Core/Repositories/IOrganizationUserRepository.cs +++ b/src/Core/Repositories/IOrganizationUserRepository.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Bit.Core.Models.Table; using Bit.Core.Models.Data; +using Bit.Core.Enums; namespace Bit.Core.Repositories { @@ -11,6 +12,7 @@ namespace Bit.Core.Repositories Task GetByOrganizationAsync(Guid organizationId, Guid userId); Task>> GetDetailsByIdAsync(Guid id); Task> GetManyDetailsByOrganizationAsync(Guid organizationId); - Task> GetManyDetailsByUserAsync(Guid userId); + Task> GetManyDetailsByUserAsync(Guid userId, + OrganizationUserStatusType? status = null); } } diff --git a/src/Core/Repositories/SqlServer/OrganizationUserRepository.cs b/src/Core/Repositories/SqlServer/OrganizationUserRepository.cs index 3a45fb54f4..3747a253bc 100644 --- a/src/Core/Repositories/SqlServer/OrganizationUserRepository.cs +++ b/src/Core/Repositories/SqlServer/OrganizationUserRepository.cs @@ -7,6 +7,7 @@ using Dapper; using System.Linq; using Bit.Core.Models.Data; using System.Collections.Generic; +using Bit.Core.Enums; namespace Bit.Core.Repositories.SqlServer { @@ -61,13 +62,14 @@ namespace Bit.Core.Repositories.SqlServer } } - public async Task> GetManyDetailsByUserAsync(Guid userId) + public async Task> GetManyDetailsByUserAsync(Guid userId, + OrganizationUserStatusType? status = null) { using(var connection = new SqlConnection(ConnectionString)) { var results = await connection.QueryAsync( - "[dbo].[OrganizationUserOrganizationDetails_ReadByUserId]", - new { UserId = userId }, + "[dbo].[OrganizationUserOrganizationDetails_ReadByUserIdStatus]", + new { UserId = userId, Status = status }, commandType: CommandType.StoredProcedure); return results.ToList(); diff --git a/src/Sql/Sql.sqlproj b/src/Sql/Sql.sqlproj index eac203fa74..5e6a09abfa 100644 --- a/src/Sql/Sql.sqlproj +++ b/src/Sql/Sql.sqlproj @@ -168,7 +168,7 @@ - + diff --git a/src/Sql/dbo/Stored Procedures/OrganizationUserOrganizationDetails_ReadByUserId.sql b/src/Sql/dbo/Stored Procedures/OrganizationUserOrganizationDetails_ReadByUserIdStatus.sql similarity index 64% rename from src/Sql/dbo/Stored Procedures/OrganizationUserOrganizationDetails_ReadByUserId.sql rename to src/Sql/dbo/Stored Procedures/OrganizationUserOrganizationDetails_ReadByUserIdStatus.sql index 88d22b5900..c9296d01d8 100644 --- a/src/Sql/dbo/Stored Procedures/OrganizationUserOrganizationDetails_ReadByUserId.sql +++ b/src/Sql/dbo/Stored Procedures/OrganizationUserOrganizationDetails_ReadByUserIdStatus.sql @@ -1,5 +1,6 @@ -CREATE PROCEDURE [dbo].[OrganizationUserOrganizationDetails_ReadByUserId] - @UserId UNIQUEIDENTIFIER +CREATE PROCEDURE [dbo].[OrganizationUserOrganizationDetails_ReadByUserIdStatus] + @UserId UNIQUEIDENTIFIER, + @Status TINYINT AS BEGIN SET NOCOUNT ON @@ -10,4 +11,5 @@ BEGIN [dbo].[OrganizationUserOrganizationDetailsView] WHERE [UserId] = @UserId + AND (@Status IS NULL OR [Status] = @Status) END \ No newline at end of file