Skip to content

Commit

Permalink
Change IsAuthorized in ResourceDto to a nullable property
Browse files Browse the repository at this point in the history
  • Loading branch information
gdlcf88 committed Apr 30, 2020
1 parent c23ff74 commit 730b4e3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Version>0.1.5</Version>
<Version>0.1.6</Version>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>EasyAbp Team</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public class ResourceDto : FullAuditedEntityDto<Guid>

public bool IsPublished { get; set; }

public bool IsAuthorized { get; set; }
public bool? IsAuthorized { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public override async Task<ResourceItemDto> GetAsync(Guid id)

var dto = await MapToGetOutputDtoAsync(resourceItem);

if (resourceItem.IsPublic || currentUserAllowedToManage || await IsCurrentUserAllowedToReadAsync(resource.Id))
if (resourceItem.IsPublic || currentUserAllowedToManage || await IsCurrentUserAuthorizedToReadAsync(resource.Id))
{
return dto;
}
Expand All @@ -91,7 +91,7 @@ public override async Task<PagedResultDto<ResourceItemDto>> GetListAsync(GetReso
{
query = query.Where(x => x.IsPublished);

if (!await IsCurrentUserAllowedToReadAsync(resource.Id))
if (!await IsCurrentUserAuthorizedToReadAsync(resource.Id))
{
query = query.Where(x => x.IsPublic);
}
Expand Down Expand Up @@ -186,7 +186,7 @@ protected virtual ResourceItemDto RemoveResourceItemContent(ResourceItemDto dto)
return dto;
}

protected virtual async Task<bool> IsCurrentUserAllowedToReadAsync(Guid resourceId)
protected virtual async Task<bool> IsCurrentUserAuthorizedToReadAsync(Guid resourceId)
{
return CurrentUser.Id.HasValue &&
await _resourceUserRepository.FindAsync(resourceId, CurrentUser.Id.Value) != null;
Expand Down

0 comments on commit 730b4e3

Please sign in to comment.