-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add account claims & login app services
- Loading branch information
Showing
8 changed files
with
150 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
.../src/Passingwind.Abp.Account.Application.Contracts/AccountAuthenticationLoginResultDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Passingwind.Abp.Account; | ||
|
||
public class AccountAuthenticationLoginResultDto | ||
{ | ||
public string LoginProvider { get; set; } = null!; | ||
public string? ProviderDisplayName { get; set; } | ||
} |
16 changes: 16 additions & 0 deletions
16
...rc/Passingwind.Abp.Account.Application.Contracts/IAccountAuthenticationLoginAppService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Threading.Tasks; | ||
using Volo.Abp.Application.Dtos; | ||
using Volo.Abp.Application.Services; | ||
|
||
namespace Passingwind.Abp.Account; | ||
|
||
public interface IAccountAuthenticationLoginAppService : IApplicationService | ||
{ | ||
Task<ListResultDto<AccountAuthenticationLoginResultDto>> GetListAsync(); | ||
} | ||
|
||
public class AccountClaimResultDto | ||
{ | ||
public string ClaimType { get; set; } = null!; | ||
public string? ClaimValue { get; set; } | ||
} |
10 changes: 10 additions & 0 deletions
10
...les/account/src/Passingwind.Abp.Account.Application.Contracts/IAccountClaimsAppService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Threading.Tasks; | ||
using Volo.Abp.Application.Dtos; | ||
using Volo.Abp.Application.Services; | ||
|
||
namespace Passingwind.Abp.Account; | ||
|
||
public interface IAccountClaimsAppService : IApplicationService | ||
{ | ||
Task<ListResultDto<AccountClaimResultDto>> GetListAsync(); | ||
} |
32 changes: 32 additions & 0 deletions
32
...s/account/src/Passingwind.Abp.Account.Application/AccountAuthenticationLoginAppService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Passingwind.Abp.Identity; | ||
using Volo.Abp.Application.Dtos; | ||
using Volo.Abp.Users; | ||
|
||
namespace Passingwind.Abp.Account; | ||
|
||
[Authorize] | ||
public class AccountAuthenticationLoginAppService : AccountAppBaseService, IAccountAuthenticationLoginAppService | ||
{ | ||
protected IdentityUserManager UserManager { get; } | ||
|
||
public AccountAuthenticationLoginAppService(IdentityUserManager userManager) | ||
{ | ||
UserManager = userManager; | ||
} | ||
|
||
public virtual async Task<ListResultDto<AccountAuthenticationLoginResultDto>> GetListAsync() | ||
{ | ||
var user = await UserManager.GetByIdAsync(CurrentUser.GetId()); | ||
|
||
var list = await UserManager.GetLoginsAsync(user); | ||
|
||
return new ListResultDto<AccountAuthenticationLoginResultDto>(list.Select(x => new AccountAuthenticationLoginResultDto() | ||
{ | ||
LoginProvider = x.LoginProvider, | ||
ProviderDisplayName = x.ProviderDisplayName, | ||
}).ToList()); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
modules/account/src/Passingwind.Abp.Account.Application/AccountClaimsAppService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Passingwind.Abp.Identity; | ||
using Volo.Abp.Application.Dtos; | ||
using Volo.Abp.Users; | ||
|
||
namespace Passingwind.Abp.Account; | ||
|
||
[Authorize] | ||
public class AccountClaimsAppService : AccountAppBaseService, IAccountClaimsAppService | ||
{ | ||
protected IdentityUserManager UserManager { get; } | ||
|
||
public AccountClaimsAppService(IdentityUserManager userManager) | ||
{ | ||
UserManager = userManager; | ||
} | ||
|
||
public virtual async Task<ListResultDto<AccountClaimResultDto>> GetListAsync() | ||
{ | ||
var user = await UserManager.GetByIdAsync(CurrentUser.GetId()); | ||
|
||
var list = await UserManager.GetClaimsAsync(user); | ||
|
||
return new ListResultDto<AccountClaimResultDto>(list.Select(x => new AccountClaimResultDto() | ||
{ | ||
ClaimType = x.Type, | ||
ClaimValue = x.Value, | ||
}).ToList()); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
modules/account/src/Passingwind.Abp.Account.HttpApi/AccountAuthenticationLoginController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Volo.Abp; | ||
using Volo.Abp.Application.Dtos; | ||
|
||
namespace Passingwind.Abp.Account; | ||
|
||
[RemoteService(Name = AccountRemoteServiceConsts.RemoteServiceName)] | ||
[Area(AccountRemoteServiceConsts.ModuleName)] | ||
[Route("api/account/authentication/logins")] | ||
public class AccountAuthenticationLoginController : AccountBaseController, IAccountAuthenticationLoginAppService | ||
{ | ||
protected IAccountAuthenticationLoginAppService Service { get; } | ||
|
||
public AccountAuthenticationLoginController(IAccountAuthenticationLoginAppService service) | ||
{ | ||
Service = service; | ||
} | ||
|
||
/// <inheritdoc/> | ||
[HttpGet] | ||
public virtual Task<ListResultDto<AccountAuthenticationLoginResultDto>> GetListAsync() | ||
{ | ||
return Service.GetListAsync(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
modules/account/src/Passingwind.Abp.Account.HttpApi/AccountClaimsController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Volo.Abp; | ||
using Volo.Abp.Application.Dtos; | ||
|
||
namespace Passingwind.Abp.Account; | ||
|
||
[RemoteService(Name = AccountRemoteServiceConsts.RemoteServiceName)] | ||
[Area(AccountRemoteServiceConsts.ModuleName)] | ||
[Route("api/account/claims")] | ||
public class AccountClaimsController : AccountBaseController, IAccountClaimsAppService | ||
{ | ||
protected IAccountClaimsAppService Service { get; } | ||
|
||
public AccountClaimsController(IAccountClaimsAppService service) | ||
{ | ||
Service = service; | ||
} | ||
|
||
/// <inheritdoc/> | ||
[HttpGet] | ||
public virtual Task<ListResultDto<AccountClaimResultDto>> GetListAsync() | ||
{ | ||
return Service.GetListAsync(); | ||
} | ||
} |