Skip to content

Commit

Permalink
fix: identity user route error
Browse files Browse the repository at this point in the history
* move user security log to account
  • Loading branch information
jxnkwlp committed Sep 14, 2023
1 parent 434f64d commit 39678f4
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 48 deletions.
2 changes: 1 addition & 1 deletion modules/account/src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<Version>0.1.0</Version>
<PackageVersion>0.1.1</PackageVersion>
<PackageVersion>0.1.4</PackageVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Threading.Tasks;
using Passingwind.Abp.Identity;
using Volo.Abp.Application.Dtos;

namespace Passingwind.Abp.Account;

public interface IAccountSecurityLogAppService
{
Task<PagedResultDto<IdentitySecurityLogDto>> GetListAsync(IdentitySecurityLogPagedListRequestDto input);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<PackageReference Include="Volo.Abp.Ddd.Application.Contracts" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Authorization" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Account.Application.Contracts" Version="$(AbpVersion)" />
<ProjectReference Include="..\..\..\identity\src\Passingwind.Abp.Identity.Application.Contracts\Passingwind.Abp.Identity.Application.Contracts.csproj" />
<ProjectReference Include="..\Passingwind.Abp.Account.Domain.Shared\Passingwind.Abp.Account.Domain.Shared.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Passingwind.Abp.Identity;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Identity;

namespace Passingwind.Abp.Account;

[Authorize]
public class AccountSecurityLogAppService : AccountAppBaseService, IAccountSecurityLogAppService
{
protected IIdentitySecurityLogRepository SecurityLogRepository { get; }

public AccountSecurityLogAppService(IIdentitySecurityLogRepository securityLogRepository)
{
SecurityLogRepository = securityLogRepository;
}

public virtual async Task<PagedResultDto<IdentitySecurityLogDto>> GetListAsync(IdentitySecurityLogPagedListRequestDto input)
{
input.UserId = CurrentUser.Id;

var count = await SecurityLogRepository.GetCountAsync(
input.StartTime,
input.EndTime,
input.ApplicationName,
input.Identity,
input.Action,
input.UserId,
input.UserName,
input.ClientId,
input.CorrelationId);

var list = await SecurityLogRepository.GetListAsync(
input.Sorting ?? nameof(IdentitySecurityLog.CreationTime) + " desc",
input.MaxResultCount,
input.SkipCount,
input.StartTime,
input.EndTime,
input.ApplicationName,
input.Identity,
input.Action,
input.UserId,
input.UserName,
input.ClientId,
input.CorrelationId);

return new PagedResultDto<IdentitySecurityLogDto>(count, ObjectMapper.Map<List<IdentitySecurityLog>, List<IdentitySecurityLogDto>>(list));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Passingwind.Abp.Identity;
using Volo.Abp;
using Volo.Abp.Application.Dtos;

namespace Passingwind.Abp.Account;

[RemoteService(Name = AccountRemoteServiceConsts.RemoteServiceName)]
[Area(AccountRemoteServiceConsts.ModuleName)]
[Route("/api/account/security-logs")]
public class AccountSecurityLogController : AccountBaseController, IAccountSecurityLogAppService
{
private readonly IAccountSecurityLogAppService _service;

public AccountSecurityLogController(IAccountSecurityLogAppService service)
{
_service = service;
}

[HttpGet]
public Task<PagedResultDto<IdentitySecurityLogDto>> GetListAsync(IdentitySecurityLogPagedListRequestDto input)
{
return _service.GetListAsync(input);
}
}
2 changes: 1 addition & 1 deletion modules/identity/src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<Version>0.1.0</Version>
<PackageVersion>0.1.3</PackageVersion>
<PackageVersion>0.1.4</PackageVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ namespace Passingwind.Abp.Identity;

public interface IIdentitySecurityLogAppService : IApplicationService
{
Task<IdentitySecurityLogDto> GetAsync(Guid id);

Task<PagedResultDto<IdentitySecurityLogDto>> GetListAsync(IdentitySecurityLogPagedListRequestDto input);

Task<PagedResultDto<IdentitySecurityLogDto>> GetListByCurrentUserAsync(IdentitySecurityLogPagedListRequestDto input);
Task<IdentitySecurityLogDto> GetAsync(Guid id);

Task DeleteAsync(Guid id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Passingwind.Abp.Identity;

[Authorize]
[Authorize(IdentityPermissionNamesV2.SecurityLogs.Default)]
public class IdentitySecurityLogAppService : IdentityAppBaseService, IIdentitySecurityLogAppService
{
protected IIdentitySecurityLogRepository SecurityLogRepository { get; }
Expand All @@ -23,15 +23,13 @@ public virtual async Task DeleteAsync(Guid id)
await SecurityLogRepository.DeleteAsync(id);
}

[Authorize(IdentityPermissionNamesV2.SecurityLogs.Default)]
public virtual async Task<IdentitySecurityLogDto> GetAsync(Guid id)
{
var entity = await SecurityLogRepository.GetAsync(id);

return ObjectMapper.Map<IdentitySecurityLog, IdentitySecurityLogDto>(entity);
}

[Authorize(IdentityPermissionNamesV2.SecurityLogs.Default)]
public virtual async Task<PagedResultDto<IdentitySecurityLogDto>> GetListAsync(IdentitySecurityLogPagedListRequestDto input)
{
var count = await SecurityLogRepository.GetCountAsync(
Expand Down Expand Up @@ -61,37 +59,4 @@ public virtual async Task<PagedResultDto<IdentitySecurityLogDto>> GetListAsync(I

return new PagedResultDto<IdentitySecurityLogDto>(count, ObjectMapper.Map<List<IdentitySecurityLog>, List<IdentitySecurityLogDto>>(list));
}

[Authorize]
public virtual async Task<PagedResultDto<IdentitySecurityLogDto>> GetListByCurrentUserAsync(IdentitySecurityLogPagedListRequestDto input)
{
input.UserId = CurrentUser.Id;

var count = await SecurityLogRepository.GetCountAsync(
input.StartTime,
input.EndTime,
input.ApplicationName,
input.Identity,
input.Action,
input.UserId,
input.UserName,
input.ClientId,
input.CorrelationId);

var list = await SecurityLogRepository.GetListAsync(
input.Sorting ?? nameof(IdentitySecurityLog.CreationTime) + " desc",
input.MaxResultCount,
input.SkipCount,
input.StartTime,
input.EndTime,
input.ApplicationName,
input.Identity,
input.Action,
input.UserId,
input.UserName,
input.ClientId,
input.CorrelationId);

return new PagedResultDto<IdentitySecurityLogDto>(count, ObjectMapper.Map<List<IdentitySecurityLog>, List<IdentitySecurityLogDto>>(list));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ public virtual Task<PagedResultDto<IdentitySecurityLogDto>> GetListAsync([FromQu
return _service.GetListAsync(input);
}

[HttpGet("my")]
public virtual Task<PagedResultDto<IdentitySecurityLogDto>> GetListByCurrentUserAsync([FromQuery] IdentitySecurityLogPagedListRequestDto input)
{
return _service.GetListByCurrentUserAsync(input);
}

[HttpDelete("{id}")]
public virtual Task DeleteAsync(Guid id)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public Task<ListResultDto<IdentityRoleDto>> GetRolesAsync(Guid id)
return _service.GetRolesAsync(id);
}

[HttpGet("{id}/assignable-roles")]
[HttpGet("assignable-roles")]
public Task<ListResultDto<IdentityRoleDto>> GetAssignableRolesAsync()
{
return _service.GetAssignableRolesAsync();
Expand Down

0 comments on commit 39678f4

Please sign in to comment.