mirror of https://github.com/abpframework/abp.git
13 changed files with 133 additions and 35 deletions
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Users; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
public interface IIdentityUserLookupAppService : IApplicationService |
|||
{ |
|||
Task<UserData> FindByIdAsync(Guid id); |
|||
|
|||
Task<UserData> FindByUserNameAsync(string userName); |
|||
} |
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Volo.Abp.Users; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
//TODO: Authorization (for clients, not users)
|
|||
public class IdentityUserLookupAppService : IdentityAppServiceBase, IIdentityUserLookupAppService |
|||
{ |
|||
protected IdentityUserRepositoryExternalUserLookupServiceProvider UserLookupServiceProvider { get; } |
|||
|
|||
public IdentityUserLookupAppService( |
|||
IdentityUserRepositoryExternalUserLookupServiceProvider userLookupServiceProvider) |
|||
{ |
|||
UserLookupServiceProvider = userLookupServiceProvider; |
|||
} |
|||
|
|||
public virtual async Task<UserData> FindByIdAsync(Guid id) |
|||
{ |
|||
var userData = await UserLookupServiceProvider.FindByIdAsync(id); |
|||
if (userData == null) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
return new UserData(userData); |
|||
} |
|||
|
|||
public virtual async Task<UserData> FindByUserNameAsync(string userName) |
|||
{ |
|||
var userData = await UserLookupServiceProvider.FindByUserNameAsync(userName); |
|||
if (userData == null) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
return new UserData(userData); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Volo.Abp.Users; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
[RemoteService] |
|||
[Area("identity")] |
|||
[ControllerName("UserLookup")] |
|||
[Route("api/identity/user-lookup")] |
|||
public class IdentityUserLookupController : AbpController, IIdentityUserLookupAppService |
|||
{ |
|||
protected IIdentityUserLookupAppService LookupAppService { get; } |
|||
|
|||
public IdentityUserLookupController(IIdentityUserLookupAppService lookupAppService) |
|||
{ |
|||
LookupAppService = lookupAppService; |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("{id}")] |
|||
public Task<UserData> FindByIdAsync(Guid id) |
|||
{ |
|||
return LookupAppService.FindByIdAsync(id); |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("by-username/{userName}")] |
|||
public Task<UserData> FindByUserNameAsync(string userName) |
|||
{ |
|||
return LookupAppService.FindByUserNameAsync(userName); |
|||
} |
|||
} |
|||
} |
|||
Binary file not shown.
Loading…
Reference in new issue