diff --git a/src/Api/Controllers/SyncController.cs b/src/Api/Controllers/SyncController.cs index 49ccfeacf..949454f9c 100644 --- a/src/Api/Controllers/SyncController.cs +++ b/src/Api/Controllers/SyncController.cs @@ -74,13 +74,13 @@ public class SyncController : Controller IEnumerable collections = null; IDictionary> collectionCiphersGroupDict = null; - IEnumerable policies = null; + IEnumerable policies = await _policyRepository.GetManyByUserIdAsync(user.Id); + if (hasEnabledOrgs) { collections = await _collectionRepository.GetManyByUserIdAsync(user.Id); var collectionCiphers = await _collectionCipherRepository.GetManyByUserIdAsync(user.Id); collectionCiphersGroupDict = collectionCiphers.GroupBy(c => c.CipherId).ToDictionary(s => s.Key); - policies = await _policyRepository.GetManyByUserIdAsync(user.Id); } var userTwoFactorEnabled = await _userService.TwoFactorIsEnabledAsync(user); diff --git a/src/Infrastructure.EntityFramework/Repositories/Queries/PolicyReadByUserIdQuery.cs b/src/Infrastructure.EntityFramework/Repositories/Queries/PolicyReadByUserIdQuery.cs index 58c06395a..9da530b01 100644 --- a/src/Infrastructure.EntityFramework/Repositories/Queries/PolicyReadByUserIdQuery.cs +++ b/src/Infrastructure.EntityFramework/Repositories/Queries/PolicyReadByUserIdQuery.cs @@ -20,8 +20,7 @@ public class PolicyReadByUserIdQuery : IQuery join o in dbContext.Organizations on ou.OrganizationId equals o.Id where ou.UserId == _userId && - ou.Status == OrganizationUserStatusType.Confirmed && - o.Enabled == true + ou.Status == OrganizationUserStatusType.Confirmed select p; return query; diff --git a/src/Sql/dbo/Stored Procedures/Policy_ReadByUserId.sql b/src/Sql/dbo/Stored Procedures/Policy_ReadByUserId.sql index 58e98670a..a4b716a24 100644 --- a/src/Sql/dbo/Stored Procedures/Policy_ReadByUserId.sql +++ b/src/Sql/dbo/Stored Procedures/Policy_ReadByUserId.sql @@ -15,5 +15,4 @@ BEGIN WHERE OU.[UserId] = @UserId AND OU.[Status] = 2 -- 2 = Confirmed - AND O.[Enabled] = 1 END \ No newline at end of file diff --git a/util/Migrator/DbScripts/2022-11-18_00_PolicyReadByUserIdRemoveEnabledOrgCheck.sql b/util/Migrator/DbScripts/2022-11-18_00_PolicyReadByUserIdRemoveEnabledOrgCheck.sql new file mode 100644 index 000000000..a2a43e36f --- /dev/null +++ b/util/Migrator/DbScripts/2022-11-18_00_PolicyReadByUserIdRemoveEnabledOrgCheck.sql @@ -0,0 +1,24 @@ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +ALTER PROCEDURE [dbo].[Policy_ReadByUserId] + @UserId UNIQUEIDENTIFIER +AS +BEGIN + SET NOCOUNT ON + + SELECT + P.* + FROM + [dbo].[PolicyView] P + INNER JOIN + [dbo].[OrganizationUser] OU ON P.[OrganizationId] = OU.[OrganizationId] + INNER JOIN + [dbo].[Organization] O ON OU.[OrganizationId] = O.[Id] + WHERE + OU.[UserId] = @UserId + AND OU.[Status] = 2 -- 2 = Confirmed +END +GO