diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/AbpJsonOptionsSetup.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/AbpJsonOptionsSetup.cs index a48d5148bd..366906f66e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/AbpJsonOptionsSetup.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/AbpJsonOptionsSetup.cs @@ -25,7 +25,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Json options.JsonSerializerOptions.Converters.Add(ServiceProvider.GetRequiredService()); options.JsonSerializerOptions.Converters.Add(ServiceProvider.GetRequiredService()); - options.JsonSerializerOptions.Converters.Add(new AbpStringToEnumConverter()); + options.JsonSerializerOptions.Converters.Add(new AbpStringToEnumFactory()); options.JsonSerializerOptions.Converters.Add(new AbpStringToBooleanConverter()); } } diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/ClientPermissionValueProvider.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/ClientPermissionValueProvider.cs index 7465acc087..7422046263 100644 --- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/ClientPermissionValueProvider.cs +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/ClientPermissionValueProvider.cs @@ -1,5 +1,6 @@ -using System.Linq; -using System.Threading.Tasks; +using System.Threading.Tasks; +using Volo.Abp.MultiTenancy; +using System.Linq; using Volo.Abp.Security.Claims; namespace Volo.Abp.Authorization.Permissions @@ -10,10 +11,12 @@ namespace Volo.Abp.Authorization.Permissions public override string Name => ProviderName; - public ClientPermissionValueProvider(IPermissionStore permissionStore) + protected ICurrentTenant CurrentTenant { get; } + + public ClientPermissionValueProvider(IPermissionStore permissionStore, ICurrentTenant currentTenant) : base(permissionStore) { - + CurrentTenant = currentTenant; } public async override Task CheckAsync(PermissionValueCheckContext context) @@ -25,9 +28,12 @@ namespace Volo.Abp.Authorization.Permissions return PermissionGrantResult.Undefined; } - return await PermissionStore.IsGrantedAsync(context.Permission.Name, Name, clientId) - ? PermissionGrantResult.Granted - : PermissionGrantResult.Undefined; + using (CurrentTenant.Change(null)) + { + return await PermissionStore.IsGrantedAsync(context.Permission.Name, Name, clientId) + ? PermissionGrantResult.Granted + : PermissionGrantResult.Undefined; + } } public async override Task CheckAsync(PermissionValuesCheckContext context) diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/UiMessageAlert.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/UiMessageAlert.razor index 35f50dea6c..ff0f0f64ff 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/UiMessageAlert.razor +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/UiMessageAlert.razor @@ -1,4 +1,4 @@ - + diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/UiMessageAlert.razor.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/UiMessageAlert.razor.cs index 901601b528..5d3e6e9cf7 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/UiMessageAlert.razor.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/UiMessageAlert.razor.cs @@ -137,5 +137,11 @@ namespace Volo.Abp.BlazoriseUI.Components return Canceled.InvokeAsync(null); } + + protected virtual void OnModalClosing(ModalClosingEventArgs eventArgs) + { + eventArgs.Cancel = eventArgs.CloseReason == CloseReason.EscapeClosing + || eventArgs.CloseReason == CloseReason.FocusLostClosing; + } } } diff --git a/framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/AbpSystemTextJsonSerializerOptionsSetup.cs b/framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/AbpSystemTextJsonSerializerOptionsSetup.cs index 9702d4078f..626e084ca6 100644 --- a/framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/AbpSystemTextJsonSerializerOptionsSetup.cs +++ b/framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/AbpSystemTextJsonSerializerOptionsSetup.cs @@ -19,7 +19,7 @@ namespace Volo.Abp.Json.SystemTextJson options.JsonSerializerOptions.Converters.Add(ServiceProvider.GetRequiredService()); options.JsonSerializerOptions.Converters.Add(ServiceProvider.GetRequiredService()); - options.JsonSerializerOptions.Converters.Add(new AbpStringToEnumConverter()); + options.JsonSerializerOptions.Converters.Add(new AbpStringToEnumFactory()); options.JsonSerializerOptions.Converters.Add(new AbpStringToBooleanConverter()); } } diff --git a/framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumConverter.cs b/framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumConverter.cs index 0de49a76b2..cead695538 100644 --- a/framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumConverter.cs +++ b/framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumConverter.cs @@ -1,16 +1,19 @@ using System; +using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; namespace Volo.Abp.Json.SystemTextJson.JsonConverters { - public class AbpStringToEnumConverter : JsonConverter + public class AbpStringToEnumConverter : JsonConverter + where T : struct, Enum { private readonly JsonStringEnumConverter _innerJsonStringEnumConverter; public AbpStringToEnumConverter() : this(namingPolicy: null, allowIntegerValues: true) { + } public AbpStringToEnumConverter(JsonNamingPolicy namingPolicy = null, bool allowIntegerValues = true) @@ -23,18 +26,18 @@ namespace Volo.Abp.Json.SystemTextJson.JsonConverters return typeToConvert.IsEnum; } - public override object Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { var newOptions = new JsonSerializerOptions(options); - newOptions.Converters.Remove(this); + newOptions.Converters.RemoveAll(x => x == this || x.GetType() == typeof(AbpStringToEnumFactory)); newOptions.Converters.Add(_innerJsonStringEnumConverter.CreateConverter(typeToConvert, newOptions)); - return JsonSerializer.Deserialize(ref reader, typeToConvert, newOptions); + return JsonSerializer.Deserialize(ref reader, newOptions); } - public override void Write(Utf8JsonWriter writer, object value, JsonSerializerOptions options) + public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options) { var newOptions = new JsonSerializerOptions(options); - newOptions.Converters.Remove(this); + newOptions.Converters.RemoveAll(x => x == this || x.GetType() == typeof(AbpStringToEnumFactory)); JsonSerializer.Serialize(writer, value, newOptions); } } diff --git a/framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumFactory.cs b/framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumFactory.cs new file mode 100644 index 0000000000..f85d74e1c3 --- /dev/null +++ b/framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumFactory.cs @@ -0,0 +1,40 @@ +using System; +using System.Reflection; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Volo.Abp.Json.SystemTextJson.JsonConverters +{ + public class AbpStringToEnumFactory : JsonConverterFactory + { + private readonly JsonNamingPolicy _namingPolicy; + private readonly bool _allowIntegerValues; + + public AbpStringToEnumFactory() + : this(namingPolicy: null, allowIntegerValues: true) + { + + } + + public AbpStringToEnumFactory(JsonNamingPolicy namingPolicy, bool allowIntegerValues) + { + _namingPolicy = namingPolicy; + _allowIntegerValues = allowIntegerValues; + } + + public override bool CanConvert(Type typeToConvert) + { + return typeToConvert.IsEnum; + } + + public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) + { + return (JsonConverter) Activator.CreateInstance( + typeof(AbpStringToEnumConverter<>).MakeGenericType(typeToConvert), + BindingFlags.Instance | BindingFlags.Public, + binder: null, + new object[] { _namingPolicy, _allowIntegerValues }, + culture: null)!; + } + } +} diff --git a/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpHybridJsonSerializer_Tests.cs b/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpHybridJsonSerializer_Tests.cs index 98f8acc7b4..eb44e51820 100644 --- a/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpHybridJsonSerializer_Tests.cs +++ b/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpHybridJsonSerializer_Tests.cs @@ -1,10 +1,8 @@ using System; using System.Collections.Generic; -using System.Reflection; using System.Text.Json; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; using Shouldly; using Volo.Abp.DependencyInjection; using Volo.Abp.Json.Newtonsoft; diff --git a/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpSystemTextJsonSerializerProvider_Tests.cs b/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpSystemTextJsonSerializerProvider_Tests.cs new file mode 100644 index 0000000000..143400c58c --- /dev/null +++ b/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpSystemTextJsonSerializerProvider_Tests.cs @@ -0,0 +1,63 @@ +using Shouldly; +using Volo.Abp.Json.SystemTextJson; +using Xunit; + +namespace Volo.Abp.Json +{ + public class AbpSystemTextJsonSerializerProvider_Tests : AbpJsonTestBase + { + private readonly AbpSystemTextJsonSerializerProvider _jsonSerializer; + + public AbpSystemTextJsonSerializerProvider_Tests() + { + _jsonSerializer = GetRequiredService(); + } + + [Fact] + public void Serialize_Deserialize_With_Boolean() + { + var json = "{\"name\":\"abp\",\"IsDeleted\":\"fAlSe\"}"; + var file = _jsonSerializer.Deserialize(json); + file.Name.ShouldBe("abp"); + file.IsDeleted.ShouldBeFalse(); + + file.IsDeleted = false; + var newJson = _jsonSerializer.Serialize(file); + newJson.ShouldBe("{\"name\":\"abp\",\"isDeleted\":false}"); + } + + [Fact] + public void Serialize_Deserialize_With_Enum() + { + var json = "{\"name\":\"abp\",\"type\":\"Exe\"}"; + var file = _jsonSerializer.Deserialize(json); + file.Name.ShouldBe("abp"); + file.Type.ShouldBe(FileType.Exe); + + var newJson = _jsonSerializer.Serialize(file); + newJson.ShouldBe("{\"name\":\"abp\",\"type\":2}"); + } + + class FileWithBoolean + { + public string Name { get; set; } + + public bool IsDeleted { get; set; } + + } + + class FileWithEnum + { + public string Name { get; set; } + + public FileType Type { get; set; } + } + + + enum FileType + { + Zip = 0, + Exe = 2 + } + } +} diff --git a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/IdentityServer/IdentityServerDataSeedContributor.cs b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/IdentityServer/IdentityServerDataSeedContributor.cs index da6f57f337..9eee928e53 100644 --- a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/IdentityServer/IdentityServerDataSeedContributor.cs +++ b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/IdentityServer/IdentityServerDataSeedContributor.cs @@ -208,7 +208,8 @@ namespace Volo.CmsKit.IdentityServer await _permissionDataSeeder.SeedAsync( ClientPermissionValueProvider.ProviderName, name, - permissions + permissions, + null ); } diff --git a/modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo/Abp/PermissionManagement/IdentityServer/ClientPermissionManagementProvider.cs b/modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo/Abp/PermissionManagement/IdentityServer/ClientPermissionManagementProvider.cs index bb4aa54de6..15d9952c74 100644 --- a/modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo/Abp/PermissionManagement/IdentityServer/ClientPermissionManagementProvider.cs +++ b/modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo/Abp/PermissionManagement/IdentityServer/ClientPermissionManagementProvider.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Authorization.Permissions; +using System.Threading.Tasks; +using Volo.Abp.Authorization.Permissions; using Volo.Abp.Guids; using Volo.Abp.MultiTenancy; @@ -19,5 +20,37 @@ namespace Volo.Abp.PermissionManagement.IdentityServer { } + + public override Task CheckAsync(string name, string providerName, string providerKey) + { + using (CurrentTenant.Change(null)) + { + return base.CheckAsync(name, providerName, providerKey); + } + } + + protected override Task GrantAsync(string name, string providerKey) + { + using (CurrentTenant.Change(null)) + { + return base.GrantAsync(name, providerKey); + } + } + + protected override Task RevokeAsync(string name, string providerKey) + { + using (CurrentTenant.Change(null)) + { + return base.RevokeAsync(name, providerKey); + } + } + + public override Task SetAsync(string name, string providerKey, bool isGranted) + { + using (CurrentTenant.Change(null)) + { + return base.SetAsync(name, providerKey, isGranted); + } + } } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/index.html b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/index.html index f4d6235b14..de63af374c 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/index.html +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/index.html @@ -8,27 +8,32 @@ - - - - - - - - - + + + + + + + + + -
Loading...
+
+
+
+
+
+
- - - - - - + + + + + + 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 5f282702bb..eb9395b846 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 +1,48 @@ - \ No newline at end of file +.spinner { + width: 40px; + height: 40px; + display: block; + position: fixed; + top: calc( 50% - ( 40px / 2) ); + right: calc( 50% - ( 40px / 2) ); +} + +.double-bounce1, .double-bounce2 { + width: 100%; + height: 100%; + border-radius: 50%; + background-color: #333; + opacity: 0.6; + position: absolute; + top: 0; + left: 0; + -webkit-animation: sk-bounce 2.0s infinite ease-in-out; + animation: sk-bounce 2.0s infinite ease-in-out; +} + +.double-bounce2 { + -webkit-animation-delay: -1.0s; + animation-delay: -1.0s; +} + +@-webkit-keyframes sk-bounce { + 0%, 100% { + -webkit-transform: scale(0.0) + } + + 50% { + -webkit-transform: scale(1.0) + } +} + +@keyframes sk-bounce { + 0%, 100% { + transform: scale(0.0); + -webkit-transform: scale(0.0); + } + + 50% { + transform: scale(1.0); + -webkit-transform: scale(1.0); + } +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs index 7397d2238f..9e2eadbcb3 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs @@ -290,7 +290,8 @@ namespace MyCompanyName.MyProjectName.IdentityServer await _permissionDataSeeder.SeedAsync( ClientPermissionValueProvider.ProviderName, name, - permissions + permissions, + null ); } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/IdentityServer/IdentityServerDataSeedContributor.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/IdentityServer/IdentityServerDataSeedContributor.cs index 53a1827dba..4128a24b9c 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/IdentityServer/IdentityServerDataSeedContributor.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/IdentityServer/IdentityServerDataSeedContributor.cs @@ -285,7 +285,8 @@ namespace MyCompanyName.MyProjectName.IdentityServer await _permissionDataSeeder.SeedAsync( ClientPermissionValueProvider.ProviderName, name, - permissions + permissions, + null ); }