mirror of https://github.com/abpframework/abp.git
16 changed files with 209 additions and 5 deletions
@ -0,0 +1,24 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace AbpDesk.Web.Mvc.Controllers |
|||
{ |
|||
//TODO: Move to Volo.Abp.Identity.AspNetCore.Mvc or a similar module as a seperated area!
|
|||
public class UsersController : AbpController |
|||
{ |
|||
private readonly IUserAppService _userAppService; |
|||
|
|||
public UsersController(IUserAppService userAppService) |
|||
{ |
|||
_userAppService = userAppService; |
|||
} |
|||
|
|||
public async Task<ActionResult> Index() |
|||
{ |
|||
var result = await _userAppService.GetAll(); |
|||
return View(result.Items); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
@model List<Volo.Abp.Identity.IdentityUserDto> |
|||
|
|||
<h2>Users</h2> |
|||
|
|||
<ul class="ticket-list"> |
|||
@foreach (var user in Model) |
|||
{ |
|||
<li data-entity-id="@user.Id"> |
|||
@user.UserName / @user.Email |
|||
</li> |
|||
} |
|||
</ul> |
|||
@ -1,5 +1,10 @@ |
|||
{ |
|||
"ConnectionStrings": { |
|||
"Default": "Server=localhost;Database=AbpDesk;Trusted_Connection=True;" |
|||
}, |
|||
"AbpIdentity": { |
|||
"HttpProxy": { |
|||
"ApiUrlBase": "http://localhost:63290/" |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,13 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
public class AbpIdentityApplicationContractsModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddAssemblyOf<AbpIdentityApplicationContractsModule>(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
using System.Reflection; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
// General Information about an assembly is controlled through the following
|
|||
// set of attributes. Change these attribute values to modify the information
|
|||
// associated with an assembly.
|
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("")] |
|||
[assembly: AssemblyProduct("Volo.Abp.Identity.HttpProxy")] |
|||
[assembly: AssemblyTrademark("")] |
|||
|
|||
// Setting ComVisible to false makes the types in this assembly not visible
|
|||
// to COM components. If you need to access a type in this assembly from
|
|||
// COM, set the ComVisible attribute to true on that type.
|
|||
[assembly: ComVisible(false)] |
|||
|
|||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|||
[assembly: Guid("00b240b6-ec44-461a-9578-ef4f1be9c688")] |
|||
@ -0,0 +1,20 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> |
|||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> |
|||
</PropertyGroup> |
|||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> |
|||
<PropertyGroup Label="Globals"> |
|||
<ProjectGuid>00b240b6-ec44-461a-9578-ef4f1be9c688</ProjectGuid> |
|||
<RootNamespace> |
|||
</RootNamespace> |
|||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> |
|||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> |
|||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> |
|||
</PropertyGroup> |
|||
<PropertyGroup> |
|||
<SchemaVersion>2.0</SchemaVersion> |
|||
</PropertyGroup> |
|||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> |
|||
</Project> |
|||
@ -0,0 +1,14 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
[DependsOn(typeof(AbpIdentityApplicationContractsModule))] |
|||
public class AbpIdentityHttpProxyModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddAssemblyOf<AbpIdentityHttpProxyModule>(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
public class AbpIdentityHttpProxyOptions |
|||
{ |
|||
public string ApiUrlBase { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
using System; |
|||
using System.Net.Http; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.Options; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Serialization; |
|||
using Volo.Abp.Application.Services.Dtos; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
public class HttpProxyUserAppService : IUserAppService |
|||
{ |
|||
private readonly AbpIdentityHttpProxyOptions _options; |
|||
|
|||
public HttpProxyUserAppService(IOptionsSnapshot<AbpIdentityHttpProxyOptions> options) |
|||
{ |
|||
_options = options.Value; |
|||
} |
|||
|
|||
public async Task<ListResultDto<IdentityUserDto>> GetAll() |
|||
{ |
|||
using (var client = new HttpClient()) |
|||
{ |
|||
var response = await client.GetAsync(_options.ApiUrlBase + "api/identity/users"); |
|||
if (!response.IsSuccessStatusCode) |
|||
{ |
|||
throw new AbpException("Remote service returns error!"); |
|||
} |
|||
|
|||
var content = await response.Content.ReadAsStringAsync(); |
|||
|
|||
return JsonConvert.DeserializeObject<ListResultDto<IdentityUserDto>>( |
|||
content, |
|||
new JsonSerializerSettings |
|||
{ |
|||
ContractResolver = new CamelCasePropertyNamesContractResolver() |
|||
}); |
|||
} |
|||
} |
|||
|
|||
public async Task<IdentityUserDto> Get(Guid id) |
|||
{ |
|||
using (var client = new HttpClient()) |
|||
{ |
|||
var response = await client.GetAsync(_options.ApiUrlBase + "api/identity/users/" + id); |
|||
if (!response.IsSuccessStatusCode) |
|||
{ |
|||
throw new AbpException("Remote service returns error!"); |
|||
} |
|||
|
|||
var content = await response.Content.ReadAsStringAsync(); |
|||
|
|||
return JsonConvert.DeserializeObject<IdentityUserDto>( |
|||
content, |
|||
new JsonSerializerSettings |
|||
{ |
|||
ContractResolver = new CamelCasePropertyNamesContractResolver() |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
{ |
|||
"version": "1.0.0-*", |
|||
|
|||
"dependencies": { |
|||
"Volo.Abp.Identity.Application.Contracts": "1.0.0-*", |
|||
"System.Net.Http": "4.3.1" |
|||
}, |
|||
|
|||
"frameworks": { |
|||
"netstandard1.6": { |
|||
"imports": "dnxcore50" |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue