fix: scope organization access by membership
This commit is contained in:
@@ -34,23 +34,20 @@ internal class GetCampaignsHandler(
|
||||
{
|
||||
IQueryable<Campaign> query = dbContext.Campaigns.AsQueryable();
|
||||
|
||||
if (!AccessScopeService.IsManager(User))
|
||||
IReadOnlyCollection<Guid> workspaceScopeIds = await accessScopeService.GetAccessibleWorkspaceIdsAsync(User, ct);
|
||||
IReadOnlyCollection<Guid> clientScopeIds = User.GetClientScopeIds();
|
||||
IReadOnlyCollection<Guid> campaignScopeIds = User.GetCampaignScopeIds();
|
||||
|
||||
query = query.Where(campaign => workspaceScopeIds.Contains(campaign.WorkspaceId));
|
||||
|
||||
if (!AccessScopeService.IsManager(User) && clientScopeIds.Count > 0)
|
||||
{
|
||||
IReadOnlyCollection<Guid> workspaceScopeIds = await accessScopeService.GetAccessibleWorkspaceIdsAsync(User, ct);
|
||||
IReadOnlyCollection<Guid> clientScopeIds = User.GetClientScopeIds();
|
||||
IReadOnlyCollection<Guid> campaignScopeIds = User.GetCampaignScopeIds();
|
||||
query = query.Where(campaign => clientScopeIds.Contains(campaign.ClientId));
|
||||
}
|
||||
|
||||
query = query.Where(campaign => workspaceScopeIds.Contains(campaign.WorkspaceId));
|
||||
|
||||
if (clientScopeIds.Count > 0)
|
||||
{
|
||||
query = query.Where(campaign => clientScopeIds.Contains(campaign.ClientId));
|
||||
}
|
||||
|
||||
if (campaignScopeIds.Count > 0)
|
||||
{
|
||||
query = query.Where(campaign => campaignScopeIds.Contains(campaign.Id));
|
||||
}
|
||||
if (!AccessScopeService.IsManager(User) && campaignScopeIds.Count > 0)
|
||||
{
|
||||
query = query.Where(campaign => campaignScopeIds.Contains(campaign.Id));
|
||||
}
|
||||
|
||||
if (request.ClientId.HasValue)
|
||||
|
||||
Reference in New Issue
Block a user