diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/AggregateRoot.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/AggregateRoot.cs index be222839cd..5d2ad56642 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/AggregateRoot.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/AggregateRoot.cs @@ -13,10 +13,10 @@ namespace Volo.Abp.Domain.Entities IHasExtraProperties, IHasConcurrencyStamp { - public Dictionary ExtraProperties { get; protected set; } + public virtual Dictionary ExtraProperties { get; protected set; } [DisableAuditing] - public string ConcurrencyStamp { get; set; } + public virtual string ConcurrencyStamp { get; set; } private readonly ICollection _localEvents = new Collection(); private readonly ICollection _distributedEvents = new Collection(); @@ -65,10 +65,10 @@ namespace Volo.Abp.Domain.Entities IHasExtraProperties, IHasConcurrencyStamp { - public Dictionary ExtraProperties { get; protected set; } + public virtual Dictionary ExtraProperties { get; protected set; } [DisableAuditing] - public string ConcurrencyStamp { get; set; } + public virtual string ConcurrencyStamp { get; set; } private readonly ICollection _localEvents = new Collection(); private readonly ICollection _distributedEvents = new Collection(); diff --git a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Users/BlogUser.cs b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Users/BlogUser.cs index 56f8287b19..0ae80c8d42 100644 --- a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Users/BlogUser.cs +++ b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Users/BlogUser.cs @@ -1,12 +1,10 @@ using System; -using System.Collections.Generic; -using Volo.Abp.Data; using Volo.Abp.Domain.Entities; using Volo.Abp.Users; namespace Volo.Blogging.Users { - public class BlogUser : AggregateRoot, IUser, IHasExtraProperties + public class BlogUser : AggregateRoot, IUser { public virtual Guid? TenantId { get; protected set; } @@ -24,16 +22,14 @@ namespace Volo.Blogging.Users public virtual bool PhoneNumberConfirmed { get; protected set; } - public virtual Dictionary ExtraProperties { get; protected set; } - protected BlogUser() { - ExtraProperties = new Dictionary(); + } public BlogUser(IUserData user) + : base(user.Id) { - Id = user.Id; Email = user.Email; Name = user.Name; Surname = user.Surname; @@ -42,8 +38,17 @@ namespace Volo.Blogging.Users PhoneNumberConfirmed = user.PhoneNumberConfirmed; UserName = user.UserName; TenantId = user.TenantId; + } - ExtraProperties = new Dictionary(); + public void Update(IUserData user) + { + Email = user.Email; + Name = user.Name; + Surname = user.Surname; + EmailConfirmed = user.EmailConfirmed; + PhoneNumber = user.PhoneNumber; + PhoneNumberConfirmed = user.PhoneNumberConfirmed; + UserName = user.UserName; } } } diff --git a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Users/BlogUserSynchronizer.cs b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Users/BlogUserSynchronizer.cs new file mode 100644 index 0000000000..6000d121f9 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Users/BlogUserSynchronizer.cs @@ -0,0 +1,39 @@ +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Domain.Entities.Events.Distributed; +using Volo.Abp.EventBus.Distributed; +using Volo.Abp.Users; + +namespace Volo.Blogging.Users +{ + public class BlogUserSynchronizer : + IDistributedEventHandler>, + ITransientDependency + { + protected IBlogUserRepository UserRepository { get; } + protected IBlogUserLookupService UserLookupService { get; } + + public BlogUserSynchronizer(IBlogUserRepository userRepository, IBlogUserLookupService userLookupService) + { + UserRepository = userRepository; + UserLookupService = userLookupService; + } + + public async Task HandleEventAsync(EntityUpdatedEto eventData) + { + var user = await UserRepository.FindAsync(eventData.Entity.Id); + if (user == null) + { + //TODO: Why needed (ask to @ebicoglu)? + user = await UserLookupService.FindByIdAsync(eventData.Entity.Id); + if (user == null) + { + return; + } + } + + user.Update(eventData.Entity); + await UserRepository.UpdateAsync(user); + } + } +} diff --git a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs index 22b68cd292..a3cc6b0745 100644 --- a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs +++ b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs @@ -29,7 +29,7 @@ namespace Volo.Blogging } [HttpGet] - [Route("read/{id}")] + [Route("read")] public Task GetForReadingAsync(GetPostInput input) { return _postAppService.GetForReadingAsync(input); diff --git a/samples/BookStore/src/Acme.BookStore.Application/BookStoreApplicationModule.cs b/samples/BookStore/src/Acme.BookStore.Application/BookStoreApplicationModule.cs index 00f57310f6..6c8ae1df2b 100644 --- a/samples/BookStore/src/Acme.BookStore.Application/BookStoreApplicationModule.cs +++ b/samples/BookStore/src/Acme.BookStore.Application/BookStoreApplicationModule.cs @@ -1,5 +1,4 @@ -using Microsoft.Extensions.DependencyInjection; -using Acme.BookStore.Permissions; +using Acme.BookStore.Permissions; using Volo.Abp.Authorization.Permissions; using Volo.Abp.AutoMapper; using Volo.Abp.Identity; @@ -25,8 +24,6 @@ namespace Acme.BookStore { options.AddProfile(); }); - - context.Services.AddAssemblyOf(); } } } diff --git a/samples/BookStore/src/Acme.BookStore.Domain/BookStoreDomainModule.cs b/samples/BookStore/src/Acme.BookStore.Domain/BookStoreDomainModule.cs index f959184126..044cbbb827 100644 --- a/samples/BookStore/src/Acme.BookStore.Domain/BookStoreDomainModule.cs +++ b/samples/BookStore/src/Acme.BookStore.Domain/BookStoreDomainModule.cs @@ -35,8 +35,6 @@ namespace Acme.BookStore { options.DefinitionProviders.Add(); }); - - context.Services.AddAssemblyOf(); } } } diff --git a/samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/EntityFrameworkCore/BookStoreEntityFrameworkCoreModule.cs b/samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/EntityFrameworkCore/BookStoreEntityFrameworkCoreModule.cs index 0a6c2aada3..c28764df91 100644 --- a/samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/EntityFrameworkCore/BookStoreEntityFrameworkCoreModule.cs +++ b/samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/EntityFrameworkCore/BookStoreEntityFrameworkCoreModule.cs @@ -21,8 +21,6 @@ namespace Acme.BookStore.EntityFrameworkCore { options.AddDefaultRepositories(); }); - - context.Services.AddAssemblyOf(); } } } diff --git a/samples/BookStore/src/Acme.BookStore.Web/BookStoreWebModule.cs b/samples/BookStore/src/Acme.BookStore.Web/BookStoreWebModule.cs index 6309f6164b..7c5b2b39d2 100644 --- a/samples/BookStore/src/Acme.BookStore.Web/BookStoreWebModule.cs +++ b/samples/BookStore/src/Acme.BookStore.Web/BookStoreWebModule.cs @@ -64,8 +64,6 @@ namespace Acme.BookStore ConfigureNavigationServices(); ConfigureAutoApiControllers(); ConfigureSwaggerServices(context.Services); - - context.Services.AddAssemblyOf(); } private void ConfigureDatabaseServices() diff --git a/samples/BookStore/test/Acme.BookStore.Application.Tests/BookStoreApplicationTestModule.cs b/samples/BookStore/test/Acme.BookStore.Application.Tests/BookStoreApplicationTestModule.cs index 9c886d9329..d1fc68319b 100644 --- a/samples/BookStore/test/Acme.BookStore.Application.Tests/BookStoreApplicationTestModule.cs +++ b/samples/BookStore/test/Acme.BookStore.Application.Tests/BookStoreApplicationTestModule.cs @@ -26,8 +26,6 @@ namespace Acme.BookStore context.Services.AddAlwaysAllowAuthorization(); ConfigureInMemorySqlite(context.Services); - - context.Services.AddAssemblyOf(); } private void ConfigureInMemorySqlite(IServiceCollection services) diff --git a/samples/BookStore/test/Acme.BookStore.Web.Tests/BookStoreWebTestModule.cs b/samples/BookStore/test/Acme.BookStore.Web.Tests/BookStoreWebTestModule.cs index 911b4ba3aa..bdd9918069 100644 --- a/samples/BookStore/test/Acme.BookStore.Web.Tests/BookStoreWebTestModule.cs +++ b/samples/BookStore/test/Acme.BookStore.Web.Tests/BookStoreWebTestModule.cs @@ -41,8 +41,6 @@ namespace Acme.BookStore { ConfigureLocalizationServices(context.Services); ConfigureNavigationServices(context.Services); - - context.Services.AddAssemblyOf(); } private static void ConfigureLocalizationServices(IServiceCollection services) diff --git a/samples/MicroserviceDemo/applications/AuthServer.Host/Pages/Index.cshtml.cs b/samples/MicroserviceDemo/applications/AuthServer.Host/Pages/Index.cshtml.cs index 0894e658dc..61b644778a 100644 --- a/samples/MicroserviceDemo/applications/AuthServer.Host/Pages/Index.cshtml.cs +++ b/samples/MicroserviceDemo/applications/AuthServer.Host/Pages/Index.cshtml.cs @@ -1,8 +1,8 @@ -using Microsoft.AspNetCore.Mvc.RazorPages; +using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; namespace AuthServer.Host.Pages { - public class IndexModel : PageModel + public class IndexModel : AbpPageModel { public void OnGet() { diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Index.cshtml b/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Index.cshtml index b01d764c94..4f80454947 100644 --- a/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Index.cshtml +++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Index.cshtml @@ -1,4 +1,17 @@ @page +@using Volo.Abp.Users @model PublicWebSite.Host.Pages.IndexModel +@inject ICurrentUser CurrentUser

Public Web Site Application

-

Welcome...

\ No newline at end of file +

Welcome...

+ +@if (CurrentUser.IsAuthenticated) +{ + Logout +} +else +{ +
+ +
+} \ No newline at end of file diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Index.cshtml.cs b/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Index.cshtml.cs index 996b92171e..3e966beca2 100644 --- a/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Index.cshtml.cs +++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Index.cshtml.cs @@ -1,16 +1,19 @@ -using System; -using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.AspNetCore.Authentication; +using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; namespace PublicWebSite.Host.Pages { - public class IndexModel : PageModel + public class IndexModel : AbpPageModel { public void OnGet() { + + } + + public async Task OnPostLoginAsync() + { + await HttpContext.ChallengeAsync("oidc"); } } } \ No newline at end of file diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml.cs b/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml.cs index 7741bbdf07..d82aa68175 100644 --- a/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml.cs +++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml.cs @@ -1,12 +1,12 @@ using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.RazorPages; using MyCompanyName.ProductManagement; using ProductManagement; using Volo.Abp.Application.Dtos; +using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; namespace PublicWebSite.Host.Pages { - public class ProductsModel : PageModel + public class ProductsModel : AbpPageModel { public ListResultDto Products { get; set; } diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/_ViewImports.cshtml b/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/_ViewImports.cshtml new file mode 100644 index 0000000000..c1da1f5f10 --- /dev/null +++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/_ViewImports.cshtml @@ -0,0 +1,4 @@ +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI +@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap +@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bundling \ No newline at end of file diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/wwwroot/files/ec882345a403be325bc539ebda211e79.jpg b/samples/MicroserviceDemo/applications/PublicWebSite.Host/wwwroot/files/ec882345a403be325bc539ebda211e79.jpg new file mode 100644 index 0000000000..be89ceb73d Binary files /dev/null and b/samples/MicroserviceDemo/applications/PublicWebSite.Host/wwwroot/files/ec882345a403be325bc539ebda211e79.jpg differ diff --git a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingService.Host.csproj b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingService.Host.csproj index 5dd5e62e1a..7261cad93b 100644 --- a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingService.Host.csproj +++ b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingService.Host.csproj @@ -24,6 +24,7 @@ + diff --git a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs index 8c05240835..e0cebe21f4 100644 --- a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs @@ -10,6 +10,7 @@ using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore.SqlServer; using Volo.Abp.EventBus.RabbitMq; using Volo.Abp.Guids; +using Volo.Abp.Identity; using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.PermissionManagement.EntityFrameworkCore; @@ -31,7 +32,8 @@ namespace BloggingService.Host typeof(AbpSettingManagementEntityFrameworkCoreModule), typeof(BloggingHttpApiModule), typeof(BloggingMongoDbModule), - typeof(BloggingApplicationModule) + typeof(BloggingApplicationModule), + typeof(AbpIdentityHttpApiClientModule) )] public class BloggingServiceHostModule : AbpModule { diff --git a/samples/MicroserviceDemo/microservices/BloggingService.Host/appsettings.json b/samples/MicroserviceDemo/microservices/BloggingService.Host/appsettings.json index eaeebbc7c3..f9c91ffc6b 100644 --- a/samples/MicroserviceDemo/microservices/BloggingService.Host/appsettings.json +++ b/samples/MicroserviceDemo/microservices/BloggingService.Host/appsettings.json @@ -7,6 +7,11 @@ "Default": "Server=localhost;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true", "Blogging": "mongodb://localhost|MsDemo_Blogging" }, + "RemoteServices": { + "Default": { + "BaseUrl": "http://localhost:65129/" + } + }, "Redis": { "Configuration": "127.0.0.1" },