From e6427992d17800f080eb8e36adb4bfcc61e982e3 Mon Sep 17 00:00:00 2001 From: maliming <6908465+maliming@users.noreply.github.com> Date: Fri, 16 Oct 2020 17:44:41 +0800 Subject: [PATCH 01/19] Update Two factor localize text. Resolve #5830 --- .../Volo/Abp/Identity/Localization/en.json | 4 ++-- .../Volo/Abp/Identity/Localization/tr.json | 4 ++-- .../Volo/Abp/Identity/Localization/zh-Hans.json | 4 ++-- .../Volo/Abp/Identity/Localization/zh-Hant.json | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json index 63ad1f2c3e..c1b4d42a04 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json @@ -79,8 +79,8 @@ "Permission:UserManagement": "User management", "Permission:UserLookup": "User lookup", "Feature:IdentityGroup": "Identity", - "Feature:TwoFactor": "Two Factor", - "Feature:TwoFactorDescription": "Two Factor", + "Feature:TwoFactor": "Two factor behaviour", + "Feature:TwoFactorDescription": "Set two factor behaviour. Optional values: Optional,Disabled,Forced", "Feature:TwoFactor.Optional": "Optional", "Feature:TwoFactor.Disabled": "Disabled", "Feature:TwoFactor.Forced": "Forced", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/tr.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/tr.json index 9bdecca7b2..73e4d50644 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/tr.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/tr.json @@ -77,8 +77,8 @@ "Permission:UserManagement": "Kullanıcı yönetimi", "Permission:UserLookup": "Kullanıcı sorgulama", "Feature:IdentityGroup": "Kimlik", - "Feature:TwoFactor": "İki faktörlü kimlik doğrulama", - "Feature:TwoFactorDescription": "İki faktörlü kimlik doğrulama", + "Feature:TwoFactor": "İki faktörlü davranış", + "Feature:TwoFactorDescription": "İki faktörlü davranış ayarlayın. İsteğe bağlı değerler: İsteğe Bağlı, Devre Dışı, Zorunlu", "Feature:TwoFactor.Optional": "İsteğe bağlı", "Feature:TwoFactor.Disabled": "Devre dışı", "Feature:TwoFactor.Forced": "Zorunlu", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hans.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hans.json index 74859aa0f3..226f429364 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hans.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hans.json @@ -78,8 +78,8 @@ "Permission:UserManagement": "用户管理", "Permission:UserLookup": "用户查询", "Feature:IdentityGroup": "身份标识", - "Feature:TwoFactor": "双因素身份验证", - "Feature:TwoFactorDescription": "双因素身份验证", + "Feature:TwoFactor": "双因素身份验证行为", + "Feature:TwoFactorDescription": "设置双因素身份验证行为. 可选值:可选,禁用,强制启用", "Feature:TwoFactor.Optional": "可选", "Feature:TwoFactor.Disabled": "禁用", "Feature:TwoFactor.Forced": "强制启用", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hant.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hant.json index dd8c9e0a17..5a4c96d111 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hant.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hant.json @@ -79,8 +79,8 @@ "Permission:UserManagement": "使用者管理", "Permission:UserLookup": "使用者查詢", "Feature:IdentityGroup": "身份識別", - "Feature:TwoFactor": "雙因素", - "Feature:TwoFactorDescription": "雙因素", + "Feature:TwoFactor": "雙因素身份驗證行為", + "Feature:TwoFactorDescription": "設置雙因素身份驗證行為. 可選值:可選,禁用,強制啟用", "Feature:TwoFactor.Optional": "選用", "Feature:TwoFactor.Disabled": "關閉", "Feature:TwoFactor.Forced": "強制啟用", From 4d69ddbc92ccae296f2ec7d60ce2983aa063a606 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 19 Oct 2020 14:30:46 +0800 Subject: [PATCH 02/19] Use sync to resolve the tenant. Resolve #5414 --- .../CookieTenantResolveContributor.cs | 9 +++++---- .../DomainTenantResolveContributor.cs | 19 ++++--------------- .../FormTenantResolveContributor.cs | 8 +++++--- .../HeaderTenantResolveContributor.cs | 9 +++++---- .../HttpTenantResolveContributerBase.cs | 13 +++++++------ .../QueryStringTenantResolveContributor.cs | 15 +++++++++++---- .../RouteTenantResolveContributor.cs | 12 ++++-------- .../ActionTenantResolveContributor.cs | 6 ++++-- .../CurrentUserTenantResolveContributor.cs | 13 +++++++------ .../MultiTenancy/ITenantResolveContributor.cs | 6 ++++-- .../Volo/Abp/MultiTenancy/ITenantResolver.cs | 5 +++-- .../TenantConfigurationProvider.cs | 2 +- .../TenantResolveContributorBase.cs | 7 ++++--- .../Volo/Abp/MultiTenancy/TenantResolver.cs | 9 ++++----- 14 files changed, 68 insertions(+), 65 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/CookieTenantResolveContributor.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/CookieTenantResolveContributor.cs index 7d4a109d9c..01d1f141b3 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/CookieTenantResolveContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/CookieTenantResolveContributor.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Http; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; using Volo.Abp.MultiTenancy; namespace Volo.Abp.AspNetCore.MultiTenancy @@ -9,9 +10,9 @@ namespace Volo.Abp.AspNetCore.MultiTenancy public override string Name => ContributorName; - protected override string GetTenantIdOrNameFromHttpContextOrNull(ITenantResolveContext context, HttpContext httpContext) + protected override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) { - return httpContext.Request?.Cookies[context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey]; + return Task.FromResult(httpContext.Request?.Cookies[context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey]); } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/DomainTenantResolveContributor.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/DomainTenantResolveContributor.cs index 90cf3bfa81..70da395c2e 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/DomainTenantResolveContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/DomainTenantResolveContributor.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Volo.Abp.MultiTenancy; using Volo.Abp.Text.Formatting; @@ -22,26 +23,14 @@ namespace Volo.Abp.AspNetCore.MultiTenancy _domainFormat = domainFormat.RemovePreFix(ProtocolPrefixes); } - protected override string GetTenantIdOrNameFromHttpContextOrNull( - ITenantResolveContext context, - HttpContext httpContext) + protected override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) { - if (httpContext.Request?.Host == null) - { - return null; - } - var hostName = httpContext.Request.Host.Host.RemovePreFix(ProtocolPrefixes); var extractResult = FormattedStringValueExtracter.Extract(hostName, _domainFormat, ignoreCase: true); context.Handled = true; - if (!extractResult.IsMatch) - { - return null; - } - - return extractResult.Matches[0].Value; + return extractResult.IsMatch ? Task.FromResult(extractResult.Matches[0].Value) : null; } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/FormTenantResolveContributor.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/FormTenantResolveContributor.cs index f334b4d434..868ef78519 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/FormTenantResolveContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/FormTenantResolveContributor.cs @@ -1,4 +1,5 @@ using System.Linq; +using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Volo.Abp.MultiTenancy; @@ -10,14 +11,15 @@ namespace Volo.Abp.AspNetCore.MultiTenancy public override string Name => ContributorName; - protected override string GetTenantIdOrNameFromHttpContextOrNull(ITenantResolveContext context, HttpContext httpContext) + protected async override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) { - if (httpContext.Request == null || !httpContext.Request.HasFormContentType || !httpContext.Request.Form.Any()) + if (!httpContext.Request.HasFormContentType) { return null; } - return httpContext.Request.Form[context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey]; + var form = await httpContext.Request.ReadFormAsync(); + return form[context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey]; } } } diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HeaderTenantResolveContributor.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HeaderTenantResolveContributor.cs index 25487f8b4d..24faa1d709 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HeaderTenantResolveContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HeaderTenantResolveContributor.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -13,9 +14,9 @@ namespace Volo.Abp.AspNetCore.MultiTenancy public override string Name => ContributorName; - protected override string GetTenantIdOrNameFromHttpContextOrNull(ITenantResolveContext context, HttpContext httpContext) + protected override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) { - if (httpContext.Request == null || httpContext.Request.Headers.IsNullOrEmpty()) + if (httpContext.Request.Headers.IsNullOrEmpty()) { return null; } @@ -33,7 +34,7 @@ namespace Volo.Abp.AspNetCore.MultiTenancy Log(context, $"HTTP request includes more than one {tenantIdKey} header value. First one will be used. All of them: {tenantIdHeader.JoinAsString(", ")}"); } - return tenantIdHeader.First(); + return Task.FromResult(tenantIdHeader.First()); } protected virtual void Log(ITenantResolveContext context, string text) @@ -44,4 +45,4 @@ namespace Volo.Abp.AspNetCore.MultiTenancy .LogWarning(text); } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HttpTenantResolveContributerBase.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HttpTenantResolveContributerBase.cs index a5cfbffeb7..18f76ee711 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HttpTenantResolveContributerBase.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HttpTenantResolveContributerBase.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using JetBrains.Annotations; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; @@ -9,7 +10,7 @@ namespace Volo.Abp.AspNetCore.MultiTenancy { public abstract class HttpTenantResolveContributorBase : TenantResolveContributorBase { - public override void Resolve(ITenantResolveContext context) + public async override Task ResolveAsync(ITenantResolveContext context) { var httpContext = context.GetHttpContext(); if (httpContext == null) @@ -19,7 +20,7 @@ namespace Volo.Abp.AspNetCore.MultiTenancy try { - ResolveFromHttpContext(context, httpContext); + await ResolveFromHttpContextAsync(context, httpContext); } catch (Exception e) { @@ -29,15 +30,15 @@ namespace Volo.Abp.AspNetCore.MultiTenancy } } - protected virtual void ResolveFromHttpContext(ITenantResolveContext context, HttpContext httpContext) + protected virtual async Task ResolveFromHttpContextAsync(ITenantResolveContext context, HttpContext httpContext) { - var tenantIdOrName = GetTenantIdOrNameFromHttpContextOrNull(context, httpContext); + var tenantIdOrName = await GetTenantIdOrNameFromHttpContextOrNullAsync(context, httpContext); if (!tenantIdOrName.IsNullOrEmpty()) { context.TenantIdOrName = tenantIdOrName; } } - protected abstract string GetTenantIdOrNameFromHttpContextOrNull([NotNull] ITenantResolveContext context, [NotNull] HttpContext httpContext); + protected abstract Task GetTenantIdOrNameFromHttpContextOrNullAsync([NotNull] ITenantResolveContext context, [NotNull] HttpContext httpContext); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/QueryStringTenantResolveContributor.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/QueryStringTenantResolveContributor.cs index 5144088d00..519c0931d1 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/QueryStringTenantResolveContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/QueryStringTenantResolveContributor.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Http; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; using Volo.Abp.MultiTenancy; namespace Volo.Abp.AspNetCore.MultiTenancy @@ -9,14 +10,20 @@ namespace Volo.Abp.AspNetCore.MultiTenancy public override string Name => ContributorName; - protected override string GetTenantIdOrNameFromHttpContextOrNull(ITenantResolveContext context, HttpContext httpContext) + protected override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) { - if (httpContext.Request == null || !httpContext.Request.QueryString.HasValue) + var tenantKey = context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey; + if (!httpContext.Request.QueryString.HasValue) { return null; } - return httpContext.Request.Query[context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey]; + if (httpContext.Request.Query.TryGetValue(tenantKey, out var tenant)) + { + Task.FromResult(tenant); + } + + return null; } } } diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/RouteTenantResolveContributor.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/RouteTenantResolveContributor.cs index 4548daeb04..2a5631ec32 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/RouteTenantResolveContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/RouteTenantResolveContributor.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; using Volo.Abp.MultiTenancy; @@ -11,15 +12,10 @@ namespace Volo.Abp.AspNetCore.MultiTenancy public override string Name => ContributorName; - protected override string GetTenantIdOrNameFromHttpContextOrNull(ITenantResolveContext context, HttpContext httpContext) + protected override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) { var tenantId = httpContext.GetRouteValue(context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey); - if (tenantId == null) - { - return null; - } - - return Convert.ToString(tenantId); + return tenantId == null ? null : Task.FromResult(Convert.ToString(tenantId)); } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/ActionTenantResolveContributor.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/ActionTenantResolveContributor.cs index c73075107e..0af00d647e 100644 --- a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/ActionTenantResolveContributor.cs +++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/ActionTenantResolveContributor.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using JetBrains.Annotations; namespace Volo.Abp.MultiTenancy @@ -18,9 +19,10 @@ namespace Volo.Abp.MultiTenancy _resolveAction = resolveAction; } - public override void Resolve(ITenantResolveContext context) + public override Task ResolveAsync(ITenantResolveContext context) { _resolveAction(context); + return Task.CompletedTask; } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/CurrentUserTenantResolveContributor.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/CurrentUserTenantResolveContributor.cs index d326421682..002a31bc6e 100644 --- a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/CurrentUserTenantResolveContributor.cs +++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/CurrentUserTenantResolveContributor.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Users; @@ -9,16 +10,16 @@ namespace Volo.Abp.MultiTenancy public override string Name => ContributorName; - public override void Resolve(ITenantResolveContext context) + public override Task ResolveAsync(ITenantResolveContext context) { var currentUser = context.ServiceProvider.GetRequiredService(); - if (currentUser.IsAuthenticated != true) + if (currentUser.IsAuthenticated) { - return; + context.Handled = true; + context.TenantIdOrName = currentUser.TenantId?.ToString(); } - context.Handled = true; - context.TenantIdOrName = currentUser.TenantId?.ToString(); + return Task.CompletedTask; } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/ITenantResolveContributor.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/ITenantResolveContributor.cs index a79cccfe66..c6d067044d 100644 --- a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/ITenantResolveContributor.cs +++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/ITenantResolveContributor.cs @@ -1,9 +1,11 @@ +using System.Threading.Tasks; + namespace Volo.Abp.MultiTenancy { public interface ITenantResolveContributor { string Name { get; } - void Resolve(ITenantResolveContext context); + Task ResolveAsync(ITenantResolveContext context); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/ITenantResolver.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/ITenantResolver.cs index b9ce83b0b9..7ab0e40366 100644 --- a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/ITenantResolver.cs +++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/ITenantResolver.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using JetBrains.Annotations; namespace Volo.Abp.MultiTenancy @@ -11,6 +12,6 @@ namespace Volo.Abp.MultiTenancy /// Tenant id, unique name or null (if could not resolve). /// [NotNull] - TenantResolveResult ResolveTenantIdOrName(); + Task ResolveTenantIdOrNameAsync(); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConfigurationProvider.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConfigurationProvider.cs index a89c44b465..81a9c72042 100644 --- a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConfigurationProvider.cs +++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConfigurationProvider.cs @@ -22,7 +22,7 @@ namespace Volo.Abp.MultiTenancy public virtual async Task GetAsync(bool saveResolveResult = false) { - var resolveResult = TenantResolver.ResolveTenantIdOrName(); + var resolveResult = await TenantResolver.ResolveTenantIdOrNameAsync(); if (saveResolveResult) { diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantResolveContributorBase.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantResolveContributorBase.cs index 8fcc22059d..f0f65b4c0f 100644 --- a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantResolveContributorBase.cs +++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantResolveContributorBase.cs @@ -1,10 +1,11 @@ +using System.Threading.Tasks; + namespace Volo.Abp.MultiTenancy { public abstract class TenantResolveContributorBase : ITenantResolveContributor { public abstract string Name { get; } - //TODO: We can make this async - public abstract void Resolve(ITenantResolveContext context); + public abstract Task ResolveAsync(ITenantResolveContext context); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantResolver.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantResolver.cs index 202ab4c293..5f3a97be2d 100644 --- a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantResolver.cs +++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantResolver.cs @@ -1,6 +1,5 @@ using System; -using System.Linq; -using JetBrains.Annotations; +using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Volo.Abp.DependencyInjection; @@ -18,7 +17,7 @@ namespace Volo.Abp.MultiTenancy _options = options.Value; } - public TenantResolveResult ResolveTenantIdOrName() + public virtual async Task ResolveTenantIdOrNameAsync() { var result = new TenantResolveResult(); @@ -28,7 +27,7 @@ namespace Volo.Abp.MultiTenancy foreach (var tenantResolver in _options.TenantResolvers) { - tenantResolver.Resolve(context); + await tenantResolver.ResolveAsync(context); result.AppliedResolvers.Add(tenantResolver.Name); @@ -43,4 +42,4 @@ namespace Volo.Abp.MultiTenancy return result; } } -} \ No newline at end of file +} From 373586960e1caaef7e188a5d53a409411fc4efd8 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 19 Oct 2020 14:39:55 +0800 Subject: [PATCH 03/19] Small refactoring. --- .../QueryStringTenantResolveContributor.cs | 15 +++------------ .../MultiTenancy/RouteTenantResolveContributor.cs | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/QueryStringTenantResolveContributor.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/QueryStringTenantResolveContributor.cs index 519c0931d1..eb05ed7b97 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/QueryStringTenantResolveContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/QueryStringTenantResolveContributor.cs @@ -12,18 +12,9 @@ namespace Volo.Abp.AspNetCore.MultiTenancy protected override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) { - var tenantKey = context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey; - if (!httpContext.Request.QueryString.HasValue) - { - return null; - } - - if (httpContext.Request.Query.TryGetValue(tenantKey, out var tenant)) - { - Task.FromResult(tenant); - } - - return null; + return httpContext.Request.QueryString.HasValue + ? Task.FromResult(httpContext.Request.Query[context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey].ToString()) + : null; } } } diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/RouteTenantResolveContributor.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/RouteTenantResolveContributor.cs index 2a5631ec32..d1c59523de 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/RouteTenantResolveContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/RouteTenantResolveContributor.cs @@ -15,7 +15,7 @@ namespace Volo.Abp.AspNetCore.MultiTenancy protected override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) { var tenantId = httpContext.GetRouteValue(context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey); - return tenantId == null ? null : Task.FromResult(Convert.ToString(tenantId)); + return tenantId != null ? Task.FromResult(Convert.ToString(tenantId)) : null; } } } From b9a1762551878402c24cdbd409e4646fd551877f Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 20 Oct 2020 09:11:09 +0800 Subject: [PATCH 04/19] Remove base call from MapToGetListOutputDtoAsync method. Resolve #5856 --- .../Volo/Abp/Application/Services/CrudAppService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs index bf2be8e8f0..fffde41ba7 100644 --- a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs +++ b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs @@ -57,7 +57,7 @@ namespace Volo.Abp.Application.Services protected override Task MapToGetListOutputDtoAsync(TEntity entity) { - return base.MapToGetOutputDtoAsync(entity); + return MapToGetOutputDtoAsync(entity); } protected override TEntityDto MapToGetListOutputDto(TEntity entity) From 5e853c2ca8c1b0ed717be23cde1f50474d551e04 Mon Sep 17 00:00:00 2001 From: Engincan VESKE <43685404+EngincanV@users.noreply.github.com> Date: Tue, 20 Oct 2020 11:49:32 +0300 Subject: [PATCH 05/19] Update Module-Development-Basics.md --- docs/en/Module-Development-Basics.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/Module-Development-Basics.md b/docs/en/Module-Development-Basics.md index e6f80233e4..4b76465a3e 100644 --- a/docs/en/Module-Development-Basics.md +++ b/docs/en/Module-Development-Basics.md @@ -57,7 +57,7 @@ public class BlogModule : AbpModule } ```` -See Configuration (TODO: link) document for more about the configuration system. +See the [Configuration](Configuration.md) document for more about the configuration system. #### Pre & Post Configure Services @@ -139,4 +139,4 @@ A depended module may depend on another module, but you only need to define your There are **two types of modules.** They don't have any structural difference but categorized by functionality and purpose: - **Framework modules**: These are **core modules of the framework** like caching, emailing, theming, security, serialization, validation, EF Core integration, MongoDB integration... etc. They do not have application/business functionalities but makes your daily development easier by providing common infrastructure, integration and abstractions. -- **Application modules**: These modules implement **specific application/business functionalities** like blogging, document management, identity management, tenant management... etc. They generally have their own entities, services, APIs and UI components. See [pre-built application modules](Modules/Index.md). \ No newline at end of file +- **Application modules**: These modules implement **specific application/business functionalities** like blogging, document management, identity management, tenant management... etc. They generally have their own entities, services, APIs and UI components. See [pre-built application modules](Modules/Index.md). From cb33ec1e225030f6d7fbe6f46c5ec1594d2b0488 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Tue, 20 Oct 2020 15:02:01 +0300 Subject: [PATCH 06/19] Update tr.json --- .../Volo/Abp/Identity/Localization/tr.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/tr.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/tr.json index 73e4d50644..09707f73c2 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/tr.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/tr.json @@ -77,11 +77,11 @@ "Permission:UserManagement": "Kullanıcı yönetimi", "Permission:UserLookup": "Kullanıcı sorgulama", "Feature:IdentityGroup": "Kimlik", - "Feature:TwoFactor": "İki faktörlü davranış", - "Feature:TwoFactorDescription": "İki faktörlü davranış ayarlayın. İsteğe bağlı değerler: İsteğe Bağlı, Devre Dışı, Zorunlu", + "Feature:TwoFactor": "İki faktörlü kimlik doğrulama", + "Feature:TwoFactorDescription": "İki faktörlü kimlik doğrulamanın talep edileceği durumu seçin", "Feature:TwoFactor.Optional": "İsteğe bağlı", - "Feature:TwoFactor.Disabled": "Devre dışı", - "Feature:TwoFactor.Forced": "Zorunlu", + "Feature:TwoFactor.Disabled": "Asla", + "Feature:TwoFactor.Forced": "Her zaman", "DisplayName:Abp.Identity.Password.RequiredLength": "Uzunluk gerekli", "DisplayName:Abp.Identity.Password.RequiredUniqueChars": "Tekil karakter gerekli", "DisplayName:Abp.Identity.Password.RequireNonAlphanumeric": "Alfasayısal olmayan karakter gerekli", From 8c8ea760e4ef5385d741d47354d6badf97fbea1f Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 21 Oct 2020 15:29:35 +0800 Subject: [PATCH 07/19] Remove some duplicate claims --- .../AbpIdentityServerBuilderExtensions.cs | 8 ++ .../AspNetIdentity/AbpUserClaimsFactory.cs | 75 +++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/AbpUserClaimsFactory.cs diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerBuilderExtensions.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerBuilderExtensions.cs index 9763ad35f0..d144208c02 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerBuilderExtensions.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerBuilderExtensions.cs @@ -1,17 +1,21 @@ using System; using System.IdentityModel.Tokens.Jwt; using System.IO; +using System.Linq; using System.Security.Cryptography; using IdentityModel; using IdentityServer4; using IdentityServer4.Configuration; using IdentityServer4.Services; +using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Newtonsoft.Json.Linq; +using Volo.Abp.DependencyInjection; using Volo.Abp.Identity; using Volo.Abp.IdentityServer.AspNetIdentity; using Volo.Abp.Security.Claims; +using IdentityUser = Volo.Abp.Identity.IdentityUser; namespace Volo.Abp.IdentityServer { @@ -32,6 +36,10 @@ namespace Volo.Abp.IdentityServer builder.AddAspNetIdentity(); builder.AddProfileService(); builder.AddResourceOwnerValidator(); + + builder.Services.Remove(builder.Services.LastOrDefault(x => x.ServiceType == typeof(IUserClaimsPrincipalFactory))); + builder.Services.AddTransient, AbpUserClaimsFactory>(); + builder.Services.AddTransient>, ObjectAccessor>(); } builder.Services.Replace(ServiceDescriptor.Transient()); diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/AbpUserClaimsFactory.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/AbpUserClaimsFactory.cs new file mode 100644 index 0000000000..9643655639 --- /dev/null +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/AbpUserClaimsFactory.cs @@ -0,0 +1,75 @@ +using System.Linq; +using System.Security.Claims; +using System.Threading.Tasks; +using IdentityModel; +using Microsoft.AspNetCore.Identity; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Identity; + +namespace Volo.Abp.IdentityServer.AspNetIdentity +{ + public class AbpUserClaimsFactory : IUserClaimsPrincipalFactory + where TUser : class + { + private readonly IObjectAccessor> _inner; + private readonly UserManager _userManager; + + public AbpUserClaimsFactory(IObjectAccessor> inner, + UserManager userManager) + { + _inner = inner; + _userManager = userManager; + } + + public async Task CreateAsync(TUser user) + { + var principal = await _inner.Value.CreateAsync(user); + var identity = principal.Identities.First(); + + if (!identity.HasClaim(x => x.Type == JwtClaimTypes.Subject)) + { + var sub = await _userManager.GetUserIdAsync(user); + identity.AddIfNotContains(new Claim(JwtClaimTypes.Subject, sub)); + } + + var username = await _userManager.GetUserNameAsync(user); + var usernameClaim = identity.FindFirst(claim => + claim.Type == _userManager.Options.ClaimsIdentity.UserNameClaimType && claim.Value == username); + if (usernameClaim != null) + { + identity.RemoveClaim(usernameClaim); + identity.AddIfNotContains(new Claim(JwtClaimTypes.PreferredUserName, username)); + } + + if (!identity.HasClaim(x => x.Type == JwtClaimTypes.Name)) + { + identity.AddIfNotContains(new Claim(JwtClaimTypes.Name, username)); + } + + if (_userManager.SupportsUserEmail) + { + var email = await _userManager.GetEmailAsync(user); + if (!string.IsNullOrWhiteSpace(email)) + { + identity.AddIfNotContains(new Claim(JwtClaimTypes.Email, email)); + identity.AddIfNotContains(new Claim(JwtClaimTypes.EmailVerified, + await _userManager.IsEmailConfirmedAsync(user) ? "true" : "false", ClaimValueTypes.Boolean)); + } + } + + if (_userManager.SupportsUserPhoneNumber) + { + var phoneNumber = await _userManager.GetPhoneNumberAsync(user); + if (!string.IsNullOrWhiteSpace(phoneNumber)) + { + identity.AddIfNotContains(new Claim(JwtClaimTypes.PhoneNumber, phoneNumber)); + identity.AddIfNotContains(new Claim(JwtClaimTypes.PhoneNumberVerified, + await _userManager.IsPhoneNumberConfirmedAsync(user) ? "true" : "false", + ClaimValueTypes.Boolean)); + } + } + + return principal; + } + } +} From 1dbc6a05545d05c486e81cc33bfe3aecbecd5c23 Mon Sep 17 00:00:00 2001 From: EngincanV Date: Wed, 21 Oct 2020 17:42:39 +0300 Subject: [PATCH 08/19] Update en.json --- .../AbpIoLocalization/Community/Localization/Resources/en.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json index 2544e50726..87db8c931a 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json @@ -84,6 +84,7 @@ "Edit": "Edit", "ProfileImageChange": "Change the profile image", "BlogItemErrorMessage": "Could not get the latest blog post details from ABP.", - "PlannedReleaseDate": "Planned release date" + "PlannedReleaseDate": "Planned release date", + "CommunityArticleRequestErrorMessage": "Could not get the latest article request from Github." } } From 30fdfb882fa37f6bf6d287d355a67cb89ddf8018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0lkay=20=C4=B0lknur?= Date: Wed, 21 Oct 2020 20:59:57 +0300 Subject: [PATCH 09/19] page alerts implementation. --- .../Themes/Basic/MainLayout.razor | 1 + .../WebAssembly/Alerts/AlertList.cs | 32 +++++++ .../WebAssembly/Alerts/AlertManager.cs | 14 ++++ .../WebAssembly/Alerts/AlertMessage.cs | 30 +++++++ .../WebAssembly/Alerts/AlertType.cs | 15 ++++ .../WebAssembly/Alerts/IAlertManager.cs | 7 ++ .../Components/AlertWrapper.cs | 10 +++ .../Components/PageAlert.razor | 16 ++++ .../Components/PageAlert.razor.cs | 83 +++++++++++++++++++ 9 files changed, 208 insertions(+) create mode 100644 framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/AlertList.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/AlertManager.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/AlertMessage.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/AlertType.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/IAlertManager.cs create mode 100644 framework/src/Volo.Abp.BlazoriseUI/Components/AlertWrapper.cs create mode 100644 framework/src/Volo.Abp.BlazoriseUI/Components/PageAlert.razor create mode 100644 framework/src/Volo.Abp.BlazoriseUI/Components/PageAlert.razor.cs diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/MainLayout.razor b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/MainLayout.razor index 0419b3be04..45496a7984 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/MainLayout.razor +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/MainLayout.razor @@ -18,6 +18,7 @@
+ @Body diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/AlertList.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/AlertList.cs new file mode 100644 index 0000000000..47a26ad9ea --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/AlertList.cs @@ -0,0 +1,32 @@ +using System.Collections.ObjectModel; + +namespace Volo.Abp.AspNetCore.Components.WebAssembly.Alerts +{ + public class AlertList : ObservableCollection + { + public void Add(AlertType type, string text, string title = null, bool dismissible = true) + { + Add(new AlertMessage(type, text, title, dismissible)); + } + + public void Info(string text, string title = null, bool dismissible = true) + { + Add(new AlertMessage(AlertType.Info, text, title, dismissible)); + } + + public void Warning(string text, string title = null, bool dismissible = true) + { + Add(new AlertMessage(AlertType.Warning, text, title, dismissible)); + } + + public void Danger(string text, string title = null, bool dismissible = true) + { + Add(new AlertMessage(AlertType.Danger, text, title, dismissible)); + } + + public void Success(string text, string title = null, bool dismissible = true) + { + Add(new AlertMessage(AlertType.Success, text, title, dismissible)); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/AlertManager.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/AlertManager.cs new file mode 100644 index 0000000000..290c36848a --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/AlertManager.cs @@ -0,0 +1,14 @@ +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.AspNetCore.Components.WebAssembly.Alerts +{ + public class AlertManager : IAlertManager, IScopedDependency + { + public AlertList Alerts { get; } + + public AlertManager() + { + Alerts = new AlertList(); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/AlertMessage.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/AlertMessage.cs new file mode 100644 index 0000000000..e8a8f3529a --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/AlertMessage.cs @@ -0,0 +1,30 @@ +using JetBrains.Annotations; + +namespace Volo.Abp.AspNetCore.Components.WebAssembly.Alerts +{ + public class AlertMessage + { + [NotNull] + public string Text + { + get => _text; + set => _text = Check.NotNullOrWhiteSpace(value, nameof(value)); + } + private string _text; + + public AlertType Type { get; set; } + + [CanBeNull] + public string Title { get; set; } + + public bool Dismissible { get; set; } + + public AlertMessage(AlertType type, [NotNull] string text, string title = null, bool dismissible = true) + { + Type = type; + Text = Check.NotNullOrWhiteSpace(text, nameof(text)); + Title = title; + Dismissible = dismissible; + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/AlertType.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/AlertType.cs new file mode 100644 index 0000000000..6a61a9995f --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/AlertType.cs @@ -0,0 +1,15 @@ +namespace Volo.Abp.AspNetCore.Components.WebAssembly.Alerts +{ + public enum AlertType + { + Default, + Primary, + Secondary, + Success, + Danger, + Warning, + Info, + Light, + Dark + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/IAlertManager.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/IAlertManager.cs new file mode 100644 index 0000000000..f30fe4c262 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Alerts/IAlertManager.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.AspNetCore.Components.WebAssembly.Alerts +{ + public interface IAlertManager + { + AlertList Alerts { get; } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/AlertWrapper.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/AlertWrapper.cs new file mode 100644 index 0000000000..d5963a532f --- /dev/null +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/AlertWrapper.cs @@ -0,0 +1,10 @@ +using Volo.Abp.AspNetCore.Components.WebAssembly.Alerts; + +namespace Volo.Abp.BlazoriseUI.Components +{ + internal class AlertWrapper + { + public AlertMessage AlertMessage { get; set; } + public bool IsVisible { get; set; } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/PageAlert.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/PageAlert.razor new file mode 100644 index 0000000000..c46747c9a6 --- /dev/null +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/PageAlert.razor @@ -0,0 +1,16 @@ +@foreach (var alert in Alerts) +{ + + @if (!string.IsNullOrEmpty(alert.AlertMessage.Title)) + { + + @alert.AlertMessage.Title + @if (alert.AlertMessage.Dismissible) + { + + } + + } + @alert.AlertMessage.Text + +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/PageAlert.razor.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/PageAlert.razor.cs new file mode 100644 index 0000000000..b0035b1f11 --- /dev/null +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/PageAlert.razor.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Linq; +using Blazorise; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Routing; +using Volo.Abp.AspNetCore.Components.WebAssembly.Alerts; + +namespace Volo.Abp.BlazoriseUI.Components +{ + public partial class PageAlert : ComponentBase, IDisposable + { + private List Alerts = new List(); + + [Inject] + protected IAlertManager AlertManager { get; set; } + + [Inject] + protected NavigationManager NavigationManager { get; set; } + + protected override void OnInitialized() + { + base.OnInitialized(); + NavigationManager.LocationChanged += NavigationManager_LocationChanged; + AlertManager.Alerts.CollectionChanged += Alerts_CollectionChanged; + + Alerts.AddRange(AlertManager.Alerts.Select(t => new AlertWrapper + { + AlertMessage = t, + IsVisible = true + })); + } + + //Since Blazor WASM doesn't support scoped dependency, we need to clear alerts on each location changed event. + private void NavigationManager_LocationChanged(object sender, LocationChangedEventArgs e) + { + AlertManager.Alerts.Clear(); + Alerts.Clear(); + } + + private void Alerts_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + { + if (e.Action == NotifyCollectionChangedAction.Add) + { + foreach (var item in e.NewItems) + { + Alerts.Add(new AlertWrapper + { + AlertMessage = (AspNetCore.Components.WebAssembly.Alerts.AlertMessage)item, + IsVisible = true + }); + } + } + StateHasChanged(); + } + + protected virtual Color GetAlertColor(AlertType alertType) + { + var color = alertType switch + { + AlertType.Info => Color.Info, + AlertType.Success => Color.Success, + AlertType.Warning => Color.Warning, + AlertType.Danger => Color.Danger, + AlertType.Dark => Color.Dark, + AlertType.Default => Color.None, + AlertType.Light => Color.Light, + AlertType.Primary => Color.Primary, + AlertType.Secondary => Color.Secondary, + _ => Color.None, + }; + + return color; + } + + public void Dispose() + { + NavigationManager.LocationChanged -= NavigationManager_LocationChanged; + AlertManager.Alerts.CollectionChanged -= Alerts_CollectionChanged; + } + } +} \ No newline at end of file From 4e714e84ec4ea2d0e5841a6b18d4f30321662273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Wed, 21 Oct 2020 21:49:55 +0300 Subject: [PATCH 10/19] Update GetSourceCommand.cs --- .../Volo/Abp/Cli/Commands/GetSourceCommand.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GetSourceCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GetSourceCommand.cs index 7cda59b999..5bf5041c22 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GetSourceCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GetSourceCommand.cs @@ -2,14 +2,11 @@ using System.IO; using System.Text; using System.Threading.Tasks; -using ICSharpCode.SharpZipLib.Core; -using ICSharpCode.SharpZipLib.Zip; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Volo.Abp.Cli.Args; using Volo.Abp.Cli.Commands.Services; using Volo.Abp.Cli.ProjectBuilding; -using Volo.Abp.Cli.ProjectBuilding.Building; using Volo.Abp.DependencyInjection; namespace Volo.Abp.Cli.Commands From 098daee44659257e8b304126e024109fbc8b03c7 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 22 Oct 2020 09:27:36 +0800 Subject: [PATCH 11/19] Update Multi-Tenancy.md --- docs/en/Multi-Tenancy.md | 3 ++- docs/zh-Hans/Multi-Tenancy.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/en/Multi-Tenancy.md b/docs/en/Multi-Tenancy.md index 03b3420ada..8cdda55af2 100644 --- a/docs/en/Multi-Tenancy.md +++ b/docs/en/Multi-Tenancy.md @@ -329,6 +329,7 @@ Configure(options => `MyCustomTenantResolveContributor` must inherit from the `TenantResolveContributorBase` (or implement the `ITenantResolveContributor`) as shown below: ````csharp +using System.Threading.Tasks; using Volo.Abp.MultiTenancy; namespace MultiTenancyDemo.Web @@ -337,7 +338,7 @@ namespace MultiTenancyDemo.Web { public override string Name => "Custom"; - public override void Resolve(ITenantResolveContext context) + public override Task ResolveAsync(ITenantResolveContext context) { //TODO... } diff --git a/docs/zh-Hans/Multi-Tenancy.md b/docs/zh-Hans/Multi-Tenancy.md index 863e9cfb4b..8e92d10673 100644 --- a/docs/zh-Hans/Multi-Tenancy.md +++ b/docs/zh-Hans/Multi-Tenancy.md @@ -127,13 +127,14 @@ namespace MyCompany.MyProject `MyCustomTenantResolveContributor`必须像下面这样实现**ITenantResolveContributor**接口: ````C# +using System.Threading.Tasks; using Volo.Abp.MultiTenancy; namespace MyCompany.MyProject { public class MyCustomTenantResolveContributor : ITenantResolveContributor { - public void Resolve(ITenantResolveContext context) + public override Task ResolveAsync(ITenantResolveContext context) { context.TenantIdOrName = ... //从其他地方获取租户id或租户名字... } From e1b8fe499ce3f384426e07247b4ee2065c30b047 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 22 Oct 2020 11:27:59 +0800 Subject: [PATCH 12/19] Change the IBrandingProvider namespace --- .../Basic/Components/Brand/Default.cshtml | 4 ++-- .../Themes/Basic/Layouts/Account.cshtml | 3 +-- .../Themes/Basic/Layouts/Application.cshtml | 5 ++--- .../Themes/Basic/Layouts/Empty.cshtml | 5 ++--- .../Components/DefaultBrandingProvider.cs | 13 ------------- .../Components/IBrandingProvider.cs | 17 ----------------- .../Branding/BloggingTestAppBrandingProvider.cs | 2 +- .../BrandingProvider.cs | 2 +- .../CmsKitBrandingProvider.cs | 2 +- .../Branding/VoloDocsBrandingProvider.cs | 2 +- ...irtualFileExplorerDemoAppBrandingProvider.cs | 2 +- .../MyProjectNameBrandingProvider.cs | 2 +- .../MyProjectNameBrandingProvider.cs | 2 +- .../MyProjectNameBrandingProvider.cs | 2 +- .../MyProjectNameBrandingProvider.cs | 2 +- 15 files changed, 16 insertions(+), 49 deletions(-) delete mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Components/DefaultBrandingProvider.cs delete mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Components/IBrandingProvider.cs diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Brand/Default.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Brand/Default.cshtml index 491594d966..b57f6da4bb 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Brand/Default.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Brand/Default.cshtml @@ -1,3 +1,3 @@ -@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components +@using Volo.Abp.Ui.Branding @inject IBrandingProvider BrandingProvider -@BrandingProvider.AppName \ No newline at end of file +@BrandingProvider.AppName diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml index 6ab5267b72..06b06c08dc 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml @@ -1,18 +1,17 @@ @using Microsoft.Extensions.Localization @using Microsoft.Extensions.Options @using Volo.Abp.AspNetCore.MultiTenancy -@using Volo.Abp.AspNetCore.Mvc.AntiForgery @using Volo.Abp.AspNetCore.Mvc.UI.Components.LayoutHook @using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy.Localization @using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling @using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.MainNavbar @using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.PageAlerts -@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components @using Volo.Abp.AspNetCore.Mvc.UI.Theming @using Volo.Abp.AspNetCore.Mvc.UI.Widgets.Components.WidgetScripts @using Volo.Abp.AspNetCore.Mvc.UI.Widgets.Components.WidgetStyles @using Volo.Abp.MultiTenancy @using Volo.Abp.Localization +@using Volo.Abp.Ui.Branding @inject IBrandingProvider BrandingProvider @inject IOptions MultiTenancyOptions @inject ICurrentTenant CurrentTenant diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Application.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Application.cshtml index d3ebd2f57f..5514145e80 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Application.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Application.cshtml @@ -1,14 +1,13 @@ -@using Volo.Abp.AspNetCore.Mvc.AntiForgery -@using Volo.Abp.AspNetCore.Mvc.UI.Components.LayoutHook +@using Volo.Abp.AspNetCore.Mvc.UI.Components.LayoutHook @using Volo.Abp.AspNetCore.Mvc.UI.Layout @using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling @using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.MainNavbar @using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.PageAlerts -@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components @using Volo.Abp.AspNetCore.Mvc.UI.Theming @using Volo.Abp.AspNetCore.Mvc.UI.Widgets.Components.WidgetScripts @using Volo.Abp.AspNetCore.Mvc.UI.Widgets.Components.WidgetStyles @using Volo.Abp.Localization +@using Volo.Abp.Ui.Branding @inject IBrandingProvider BrandingProvider @inject IPageLayout PageLayout @{ diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Empty.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Empty.cshtml index 2176782a70..70c7d5e1e8 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Empty.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Empty.cshtml @@ -1,13 +1,12 @@ -@using Volo.Abp.AspNetCore.Mvc.AntiForgery -@using Volo.Abp.AspNetCore.Mvc.UI.Components.LayoutHook +@using Volo.Abp.AspNetCore.Mvc.UI.Components.LayoutHook @using Volo.Abp.AspNetCore.Mvc.UI.Layout @using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling @using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.PageAlerts -@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components @using Volo.Abp.AspNetCore.Mvc.UI.Theming @using Volo.Abp.AspNetCore.Mvc.UI.Widgets.Components.WidgetScripts @using Volo.Abp.AspNetCore.Mvc.UI.Widgets.Components.WidgetStyles @using Volo.Abp.Localization +@using Volo.Abp.Ui.Branding @inject IBrandingProvider BrandingProvider @inject IPageLayout PageLayout @{ diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Components/DefaultBrandingProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Components/DefaultBrandingProvider.cs deleted file mode 100644 index a85c03364c..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Components/DefaultBrandingProvider.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Volo.Abp.DependencyInjection; - -namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components -{ - public class DefaultBrandingProvider : IBrandingProvider, ITransientDependency - { - public virtual string AppName => "MyApplication"; - - public virtual string LogoUrl => null; - - public virtual string LogoReverseUrl => null; - } -} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Components/IBrandingProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Components/IBrandingProvider.cs deleted file mode 100644 index 1c20f7fc6e..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Components/IBrandingProvider.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components -{ - public interface IBrandingProvider - { - string AppName { get; } - - /// - /// Logo on white background - /// - string LogoUrl { get; } - - /// - /// Logo on dark background - /// - string LogoReverseUrl { get; } - } -} diff --git a/modules/blogging/app/Volo.BloggingTestApp/Branding/BloggingTestAppBrandingProvider.cs b/modules/blogging/app/Volo.BloggingTestApp/Branding/BloggingTestAppBrandingProvider.cs index e5a8046ff7..ab14f6fd0a 100644 --- a/modules/blogging/app/Volo.BloggingTestApp/Branding/BloggingTestAppBrandingProvider.cs +++ b/modules/blogging/app/Volo.BloggingTestApp/Branding/BloggingTestAppBrandingProvider.cs @@ -1,5 +1,5 @@ using Microsoft.AspNetCore.Mvc.Localization; -using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components; +using Volo.Abp.Ui.Branding; using Volo.Abp.DependencyInjection; using Volo.Blogging.Localization; diff --git a/modules/client-simulation/demo/Volo.ClientSimulation.Demo/BrandingProvider.cs b/modules/client-simulation/demo/Volo.ClientSimulation.Demo/BrandingProvider.cs index c512e1a18a..fe69b3d1ad 100644 --- a/modules/client-simulation/demo/Volo.ClientSimulation.Demo/BrandingProvider.cs +++ b/modules/client-simulation/demo/Volo.ClientSimulation.Demo/BrandingProvider.cs @@ -1,4 +1,4 @@ -using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components; +using Volo.Abp.Ui.Branding; using Volo.Abp.DependencyInjection; namespace Volo.ClientSimulation.Demo diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitBrandingProvider.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitBrandingProvider.cs index 6d638730e7..c776e1063b 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitBrandingProvider.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitBrandingProvider.cs @@ -1,4 +1,4 @@ -using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components; +using Volo.Abp.Ui.Branding; using Volo.Abp.DependencyInjection; namespace Volo.CmsKit diff --git a/modules/docs/app/VoloDocs.Web/Branding/VoloDocsBrandingProvider.cs b/modules/docs/app/VoloDocs.Web/Branding/VoloDocsBrandingProvider.cs index 9c906767aa..613ef6a8df 100644 --- a/modules/docs/app/VoloDocs.Web/Branding/VoloDocsBrandingProvider.cs +++ b/modules/docs/app/VoloDocs.Web/Branding/VoloDocsBrandingProvider.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Localization; -using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components; +using Volo.Abp.Ui.Branding; using Volo.Abp.DependencyInjection; using Volo.Docs.Localization; diff --git a/modules/virtual-file-explorer/app/Volo.Abp.VirtualFileExplorer.DemoApp/Branding/AbpVirtualFileExplorerDemoAppBrandingProvider.cs b/modules/virtual-file-explorer/app/Volo.Abp.VirtualFileExplorer.DemoApp/Branding/AbpVirtualFileExplorerDemoAppBrandingProvider.cs index 369e4fde1e..ae8964cd1c 100644 --- a/modules/virtual-file-explorer/app/Volo.Abp.VirtualFileExplorer.DemoApp/Branding/AbpVirtualFileExplorerDemoAppBrandingProvider.cs +++ b/modules/virtual-file-explorer/app/Volo.Abp.VirtualFileExplorer.DemoApp/Branding/AbpVirtualFileExplorerDemoAppBrandingProvider.cs @@ -1,4 +1,4 @@ -using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components; +using Volo.Abp.Ui.Branding; using Volo.Abp.DependencyInjection; namespace Volo.Abp.VirtualFileExplorer.DemoApp.Branding diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameBrandingProvider.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameBrandingProvider.cs index aba2d3920e..3f6994c9e4 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameBrandingProvider.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameBrandingProvider.cs @@ -1,4 +1,4 @@ -using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components; +using Volo.Abp.Ui.Branding; using Volo.Abp.DependencyInjection; namespace MyCompanyName.MyProjectName diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs index ce09452496..f330fbf665 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs @@ -1,4 +1,4 @@ -using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components; +using Volo.Abp.Ui.Branding; using Volo.Abp.DependencyInjection; namespace MyCompanyName.MyProjectName.Web diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameBrandingProvider.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameBrandingProvider.cs index ce09452496..f330fbf665 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameBrandingProvider.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameBrandingProvider.cs @@ -1,4 +1,4 @@ -using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components; +using Volo.Abp.Ui.Branding; using Volo.Abp.DependencyInjection; namespace MyCompanyName.MyProjectName.Web diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs index aba2d3920e..3f6994c9e4 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs @@ -1,4 +1,4 @@ -using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components; +using Volo.Abp.Ui.Branding; using Volo.Abp.DependencyInjection; namespace MyCompanyName.MyProjectName From aecb3534fcc640b2e035d6138de2bccc05653f8e Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 22 Oct 2020 12:57:53 +0800 Subject: [PATCH 13/19] Prevent ReflectionHelper's GetValueByPath method use null values. Fix #5619 --- .../Volo/Abp/Reflection/ReflectionHelper.cs | 16 ++++-- .../Abp/Reflection/ReflectionHelper_Tests.cs | 49 ++++++++++++++++++- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/ReflectionHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/ReflectionHelper.cs index fd47d8b859..132c198aa9 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/ReflectionHelper.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/ReflectionHelper.cs @@ -124,7 +124,7 @@ namespace Volo.Abp.Reflection ? customAttributes.Concat(declaringTypeCustomAttributes).Distinct() : customAttributes; } - + /// /// Gets value of a property by it's full path from given object /// @@ -134,7 +134,7 @@ namespace Volo.Abp.Reflection var currentType = objectType; var objectPath = currentType.FullName; var absolutePropertyPath = propertyPath; - if (absolutePropertyPath.StartsWith(objectPath)) + if (objectPath != null && absolutePropertyPath.StartsWith(objectPath)) { absolutePropertyPath = absolutePropertyPath.Replace(objectPath + ".", ""); } @@ -142,8 +142,16 @@ namespace Volo.Abp.Reflection foreach (var propertyName in absolutePropertyPath.Split('.')) { var property = currentType.GetProperty(propertyName); - value = property.GetValue(value, null); - currentType = property.PropertyType; + if (property != null) + { + value = property.GetValue(value, null); + currentType = property.PropertyType; + } + else + { + value = null; + break; + } } return value; diff --git a/framework/test/Volo.Abp.Core.Tests/Volo/Abp/Reflection/ReflectionHelper_Tests.cs b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/Reflection/ReflectionHelper_Tests.cs index 333ea2e84a..9a621d3e01 100644 --- a/framework/test/Volo.Abp.Core.Tests/Volo/Abp/Reflection/ReflectionHelper_Tests.cs +++ b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/Reflection/ReflectionHelper_Tests.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using Shouldly; using Xunit; @@ -8,6 +9,50 @@ namespace Volo.Abp.Reflection { //TODO: ... + class GetValueByPathTestClass + { + public string Name { get; set; } + + public int Count { get; set; } + + public DateTime Time { get; set; } + + public GetValueByPathTestChildrenClass Children { get; set; } + } + + class GetValueByPathTestChildrenClass + { + public string Name { get; set; } + + public int Count { get; set; } + } + + [Fact] + public void GetValueByPath_Test() + { + var value = new GetValueByPathTestClass + { + Name = "test", + Count = 8, + Time = DateTime.Parse("2020-01-01"), + Children = new GetValueByPathTestChildrenClass + { + Name = "test-children", + Count = 9, + } + }; + + ReflectionHelper.GetValueByPath(value, value.GetType(), "Name").ShouldBe("test"); + ReflectionHelper.GetValueByPath(value, value.GetType(), "Volo.Abp.Reflection.ReflectionHelper_Tests+GetValueByPathTestClass.Name").ShouldBe("test"); + ReflectionHelper.GetValueByPath(value, value.GetType(), "Count").ShouldBe(8); + ReflectionHelper.GetValueByPath(value, value.GetType(), "Time").ShouldBe(DateTime.Parse("2020-01-01")); + ReflectionHelper.GetValueByPath(value, value.GetType(), "Children.Name").ShouldBe("test-children"); + ReflectionHelper.GetValueByPath(value, value.GetType(), "Children.Count").ShouldBe(9); + ReflectionHelper.GetValueByPath(value, value.GetType(), "Volo.Abp.Reflection.ReflectionHelper_Tests+GetValueByPathTestClass.Children.Name").ShouldBe("test-children"); + + ReflectionHelper.GetValueByPath(value, value.GetType(), "Children.NotExist").ShouldBeNull(); + ReflectionHelper.GetValueByPath(value, value.GetType(), "NotExist").ShouldBeNull(); + } [Fact] public void GetPublicConstantsRecursively_Test() @@ -99,4 +144,4 @@ namespace Volo.Abp.Reflection } } -} \ No newline at end of file +} From 10d735c01c2057da20aea6c2757773cc97e42013 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 22 Oct 2020 15:37:10 +0800 Subject: [PATCH 14/19] Define abp.features API to abp.js --- .../UI/AspNetCore/JavaScript-API/Features.md | 22 +++++++++++++++---- npm/packs/core/src/abp.js | 15 +++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/docs/en/UI/AspNetCore/JavaScript-API/Features.md b/docs/en/UI/AspNetCore/JavaScript-API/Features.md index e3cd2be445..8d58347f49 100644 --- a/docs/en/UI/AspNetCore/JavaScript-API/Features.md +++ b/docs/en/UI/AspNetCore/JavaScript-API/Features.md @@ -6,10 +6,24 @@ ## Basic Usage -`abp.features.values` can be used to access to the all feature values. - ````js -var excelExportFeatureValue = abp.features.values["ExportingToExcel"]; +//Gets a value as string. +var value = abp.features.get('ExportingToExcel'); + +//Check the feature is enabled +var enabled = abp.features.isEnabled('ExportingToExcel.Enabled'); ```` -Then you can check the value of the feature to perform your logic. \ No newline at end of file +## All Values + +`abp.features.values` can be used to access to the all feature values. + +An example value of this object is shown below: + +````js +{ + Identity.TwoFactor: "Optional", + ExportingToExcel.Enabled: "true", + ... +} +```` \ No newline at end of file diff --git a/npm/packs/core/src/abp.js b/npm/packs/core/src/abp.js index 72af4bd106..9405310771 100644 --- a/npm/packs/core/src/abp.js +++ b/npm/packs/core/src/abp.js @@ -750,5 +750,20 @@ var abp = abp || {}; return toUtc(date); } }; + + /* FEATURES *************************************************/ + abp.features = abp.features || {}; + + abp.features.values = abp.features.values || {}; + + abp.features.isEnabled = function(name){ + var value = abp.features.get(name); + return value == 'true' || value == 'True'; + } + + abp.features.get = function (name) { + return abp.features.values[name]; + }; + })(); From 6ab3115002dbcacfe0f83b6d9107e290bbdd4102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 22 Oct 2020 11:55:34 +0300 Subject: [PATCH 15/19] Update main.css --- .../wwwroot/main.css | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/main.css b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/main.css index 23e0f7a249..5f282702bb 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/main.css +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/main.css @@ -1,18 +1 @@ -#blazor-error-ui { - background: lightyellow; - bottom: 0; - box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); - display: none; - left: 0; - padding: 0.6rem 1.25rem 0.7rem 1.25rem; - position: fixed; - width: 100%; - z-index: 1000; -} - -#blazor-error-ui .dismiss { - cursor: pointer; - position: absolute; - right: 0.75rem; - top: 0.5rem; -} \ No newline at end of file + \ No newline at end of file From 04dc950903d88a29226f70b29d30a0b982327632 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 22 Oct 2020 19:39:00 +0800 Subject: [PATCH 16/19] Update Abp-4_0.md --- docs/en/Migration-Guides/Abp-4_0.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/en/Migration-Guides/Abp-4_0.md b/docs/en/Migration-Guides/Abp-4_0.md index 6b4b1d5096..af88b7b768 100644 --- a/docs/en/Migration-Guides/Abp-4_0.md +++ b/docs/en/Migration-Guides/Abp-4_0.md @@ -14,6 +14,10 @@ As the **most important breaking change**, Identity Server 4.x places the `ApiSc Also, added `Enabled(string)` and `Description(bool,true)` properties. +#### ApiResource + +* Added `AllowedAccessTokenSigningAlgorithms (string)` and `ShowInDiscoveryDocument(bool, default: true)` properties + #### Client * Added `RequireRequestObject (bool)` and `AllowedIdentityTokenSigningAlgorithms (string)` properties. @@ -26,11 +30,7 @@ Also, added `Enabled(string)` and `Description(bool,true)` properties. #### PersistedGrant -* Added `SessionId (string)` and `ShowInDiscoveryDocument (bool, default: true)` properties - -#### ApiResource - -* Added `AllowedAccessTokenSigningAlgorithms (string)` and `Description (string)` and `ConsumedTime (DateTime?)` properties +* Added `SessionId (string)` and `Description(string)` and `ConsumedTime (DateTime?)` properties ## Migrating the Database From a6a5f5aca99db7d511fbd8fcf5756008fdf83ee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 22 Oct 2020 16:03:05 +0300 Subject: [PATCH 17/19] Resolved #5527 and Resolved #3483 --- ...bpAspNetCoreComponentsWebAssemblyModule.cs | 8 +++- .../WebAssembly/AbpComponentActivator.cs | 32 ++++++++++++++ .../AbpWebAssemblyConventionalRegistrar.cs | 43 +++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpComponentActivator.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpWebAssemblyConventionalRegistrar.cs diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs index 707952f7c4..6664ec773a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs @@ -1,4 +1,6 @@ -using Microsoft.Extensions.DependencyInjection; +using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; using Volo.Abp.AspNetCore.Components.WebAssembly.ExceptionHandling; using Volo.Abp.AspNetCore.Mvc.Client; @@ -16,6 +18,8 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly { public override void PreConfigureServices(ServiceConfigurationContext context) { + context.Services.AddConventionalRegistrar(new AbpWebAssemblyConventionalRegistrar()); + PreConfigure(options => { options.ProxyClientBuildActions.Add((_, builder) => @@ -27,6 +31,8 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly public override void ConfigureServices(ServiceConfigurationContext context) { + context.Services.Replace(ServiceDescriptor.Transient()); + context.Services .GetHostBuilder().Logging .AddProvider(new AbpExceptionHandlingLoggerProvider(context.Services)); diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpComponentActivator.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpComponentActivator.cs new file mode 100644 index 0000000000..9d9666ad3c --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpComponentActivator.cs @@ -0,0 +1,32 @@ +using System; +using Microsoft.AspNetCore.Components; + +namespace Volo.Abp.AspNetCore.Components.WebAssembly +{ + public class ServiceProviderComponentActivator : IComponentActivator + { + public IServiceProvider ServiceProvider { get; } + + public ServiceProviderComponentActivator(IServiceProvider serviceProvider) + { + ServiceProvider = serviceProvider; + } + + public IComponent CreateInstance(Type componentType) + { + var instance = ServiceProvider.GetService(componentType); + + if (instance == null) + { + instance = Activator.CreateInstance(componentType); + } + + if (!(instance is IComponent component)) + { + throw new ArgumentException($"The type {componentType.FullName} does not implement {nameof(IComponent)}.", nameof(componentType)); + } + + return component; + } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpWebAssemblyConventionalRegistrar.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpWebAssemblyConventionalRegistrar.cs new file mode 100644 index 0000000000..91afb0eadf --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpWebAssemblyConventionalRegistrar.cs @@ -0,0 +1,43 @@ +using System; +using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.AspNetCore.Components.WebAssembly +{ + public class AbpWebAssemblyConventionalRegistrar : ConventionalRegistrarBase + { + public override void AddType(IServiceCollection services, Type type) + { + if (IsConventionalRegistrationDisabled(type)) + { + return; + } + + if (!IsComponent(type)) + { + return; + } + + var serviceTypes = ExposedServiceExplorer.GetExposedServices(type); + + TriggerServiceExposing(services, type, serviceTypes); + + foreach (var serviceType in serviceTypes) + { + services.Add( + ServiceDescriptor.Describe( + serviceType, + type, + ServiceLifetime.Transient + ) + ); + } + } + + private static bool IsComponent(Type type) + { + return typeof(ComponentBase).IsAssignableFrom(type); + } + } +} From 48dd0e2b106b244d98042801ef07e4a57d7b448e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 22 Oct 2020 16:09:20 +0300 Subject: [PATCH 18/19] Update ServiceProviderComponentActivator.cs --- ...ComponentActivator.cs => ServiceProviderComponentActivator.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/{AbpComponentActivator.cs => ServiceProviderComponentActivator.cs} (100%) diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpComponentActivator.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/ServiceProviderComponentActivator.cs similarity index 100% rename from framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpComponentActivator.cs rename to framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/ServiceProviderComponentActivator.cs From cc7b340e03dc1f2e6645898e3e788fa01cf3bb36 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 22 Oct 2020 21:37:31 +0800 Subject: [PATCH 19/19] Use userName instead of username for Identity's FindByUsernameAsync. Fix #5897 --- .../Volo/Abp/Identity/IIdentityUserAppService.cs | 2 +- .../Volo/Abp/Identity/IdentityUserAppService.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityUserAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityUserAppService.cs index 97f443f3b6..db6cbdfe38 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityUserAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityUserAppService.cs @@ -19,7 +19,7 @@ namespace Volo.Abp.Identity Task UpdateRolesAsync(Guid id, IdentityUserUpdateRolesDto input); - Task FindByUsernameAsync(string username); + Task FindByUsernameAsync(string userName); Task FindByEmailAsync(string email); } diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs index 070a452218..acd573f916 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs @@ -135,10 +135,10 @@ namespace Volo.Abp.Identity } [Authorize(IdentityPermissions.Users.Default)] - public virtual async Task FindByUsernameAsync(string username) + public virtual async Task FindByUsernameAsync(string userName) { return ObjectMapper.Map( - await UserManager.FindByNameAsync(username) + await UserManager.FindByNameAsync(userName) ); }