diff --git a/docs/en/Modules/Index.md b/docs/en/Modules/Index.md index d5037665f0..5e280268e7 100644 --- a/docs/en/Modules/Index.md +++ b/docs/en/Modules/Index.md @@ -4,8 +4,8 @@ ABP is a **modular application framework** which consists of dozens of **NuGet & There are **two types of modules.** They don't have any structural difference but are categorized by functionality and purpose: -* [**Framework modules**](https://github.com/abpframework/abp/tree/master/framework/src): 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**](https://github.com/abpframework/abp/tree/master/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. +* [**Framework modules**](https://github.com/abpframework/abp/tree/dev/framework/src): 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**](https://github.com/abpframework/abp/tree/dev/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. ## Open Source Application Modules @@ -29,4 +29,4 @@ See [the GitHub repository](https://github.com/abpframework/abp/tree/dev/modules ## Commercial Application Modules -[ABP Commercial](https://commercial.abp.io/) license provides **additional pre-built application modules** on top of the ABP framework. See the [module list](https://commercial.abp.io/modules) provided by the ABP Commercial. \ No newline at end of file +[ABP Commercial](https://commercial.abp.io/) license provides **additional pre-built application modules** on top of the ABP framework. See the [module list](https://commercial.abp.io/modules) provided by the ABP Commercial. diff --git a/docs/en/Modules/Setting-Management.md b/docs/en/Modules/Setting-Management.md index 354fbdd539..e26c7c806e 100644 --- a/docs/en/Modules/Setting-Management.md +++ b/docs/en/Modules/Setting-Management.md @@ -177,7 +177,8 @@ public class BookStoreSettingPageContributor : ISettingPageContributor new SettingPageGroup( "Volo.Abp.MySettingGroup", "MySettingGroup", - typeof(MySettingGroupViewComponent) + typeof(MySettingGroupViewComponent), + order : 1 ) ); @@ -240,7 +241,8 @@ public class BookStoreSettingComponentContributor : ISettingComponentContributor new SettingComponentGroup( "Volo.Abp.MySettingGroup", "MySettingGroup", - typeof(MySettingGroupComponent) + typeof(MySettingGroupComponent), + order : 1 ) ); diff --git a/docs/en/Modules/Tenant-Management.md b/docs/en/Modules/Tenant-Management.md index e12b6fc7a6..0d43c5e31e 100644 --- a/docs/en/Modules/Tenant-Management.md +++ b/docs/en/Modules/Tenant-Management.md @@ -48,6 +48,33 @@ The Features action opens a modal to enable/disable/set [features](../Features.m *Manage Host features* button is used to set features for the host side, if you use the features of your application also in the host side. +## Distributed Events + +This module defines the following ETOs (Event Transfer Objects) to allow you to subscribe to changes on the entities of the module; + +- `TenantEto` is published on changes done on an `Tenant` entity. + +**Example: Get notified when a new tenant has been created** + +``` +public class MyHandler : + IDistributedEventHandler>, + ITransientDependency +{ + public async Task HandleEventAsync(EntityCreatedEto eventData) + { + TenantEto tenant = eventData.Entity; + // TODO: ... + } +} +``` + + + +`TenantEto` is configured to automatically publish the events. You should configure yourself for the others. See the [Distributed Event Bus document](https://github.com/abpframework/abp/blob/rel-7.3/docs/en/Distributed-Event-Bus.md) to learn details of the pre-defined events. + +> Subscribing to the distributed events is especially useful for distributed scenarios (like microservice architecture). If you are building a monolithic application, or listening events in the same process that runs the Tenant Management Module, then subscribing to the [local events](https://github.com/abpframework/abp/blob/rel-7.3/docs/en/Local-Event-Bus.md) can be more efficient and easier. + ## Internals This section can be used as a reference if you want to [customize](../Customizing-Application-Modules-Guide.md) this module without changing [its source code](https://github.com/abpframework/abp/tree/dev/modules/tenant-management). diff --git a/docs/en/UI/Angular/CapsLock.directive.md b/docs/en/UI/Angular/CapsLock.directive.md new file mode 100644 index 0000000000..64a3fc42ca --- /dev/null +++ b/docs/en/UI/Angular/CapsLock.directive.md @@ -0,0 +1,80 @@ +# Caps Lock Directive + +In password inputs, You may want to show if Caps Lock is on. To make this even easier, you can use the `TrackCapsLockDirective` which has been exposed by the `@abp/ng.core` package. + + +## Getting Started + +`TrackCapsLockDirective` is standalone. In order to use the `TrackCapsLockDirective` in an HTML template, import it to related module or your standalone component: + +**Importing to NgModule** +```ts +import { TrackCapsLockDirective } from '@abp/ng.core'; + +@NgModule({ + //... + declarations: [ + ..., + TestComponent + ], + imports: [ + ..., + TrackCapsLockDirective + ], +}) +export class MyFeatureModule {} +``` + +## Usage + +The `TrackCapsLockDirective` is very easy to use. The directive's selector is **`abpCapsLock`**. By adding the `abpCapsLock` event to an element, you can track the status of Caps Lock. You can use this to warn user. + +See an example usage: + +**NgModule Component usage** +```ts +@Component({ + selector: 'test-component', + template: ` +
+ + + icon +
+ ` +}) +export class TestComponent{ + capsLock = false; +} +``` + +**Standalone Component usage** +```ts +import { TrackCapsLockDirective } from '@abp/ng.core' + +@Component({ + selector: 'standalone-component', + standalone: true, + template: ` +
+ + + icon +
+ `, + imports: [TrackCapsLockDirective] +}) +export class StandaloneComponent{ + capsLock = false; +} +``` + +The `abpCapsLock` event has been added to the `` element. Press Caps Lock to activate the `TrackCapsLockDirective`. + +See the result: + +![Show Password directive](./images/CapsLockDirective1.png) + +To see Caps Lock icon press Caps Lock. + +![Show Password directive](./images/CapsLockDirective2.png) diff --git a/docs/en/UI/Angular/Show-Password-Directive.md b/docs/en/UI/Angular/Show-Password-Directive.md new file mode 100644 index 0000000000..c19c8073bd --- /dev/null +++ b/docs/en/UI/Angular/Show-Password-Directive.md @@ -0,0 +1,77 @@ +# Show Password Directive + +In password input, text can be shown easily via changing input type attribute to `text`. To make this even easier, you can use the `ShowPasswordDirective` which has been exposed by the `@abp/ng.core` package. + + +## Getting Started +`ShowPasswordDirective` is standalone. In order to use the `ShowPasswordDirective` in an HTML template, import it to related module or your standalone component: + +**Importing to NgModule** +```ts +import { ShowPasswordDirective } from '@abp/ng.core'; + +@NgModule({ + //... + declarations: [ + ..., + TestComponent + ], + imports: [ + ..., + ShowPasswordDirective + ], +}) +export class MyFeatureModule {} +``` + +## Usage + +The `ShowPasswordDirective` is very easy to use. The directive's selector is **`abpShowPassword`**. By adding the `abpShowPassword` attribute to an input element, you can activate the `ShowPasswordDirective` for the input element. + +See an example usage: + +**NgModule Component usage** +```ts +@Component({ + selector: 'test-component', + template: ` +
+ + + icon +
+ ` +}) +export class TestComponent{ + showPassword = false; +} +``` +**Standalone Component usage** +```ts +import { ShowPasswordDirective } from '@abp/ng.core'; +@Component({ + selector: 'standalone-component', + standalone: true, + template: ` +
+ + + icon +
+ `, + imports: [ShowPasswordDirective] +}) +export class StandaloneComponent{ + showPassword = false; +} +``` + +The `abpShowPassword` attribute has been added to the `` element. Click icon to activate the `ShowPasswordDirective`. + +See the result: + +![Show Password directive](./images/showPasswordDirective1.png) + +To see password input click icon. + +![Show Password directive](./images/showPasswordDirective2.png) diff --git a/docs/en/UI/Angular/images/CapsLockDirective1.png b/docs/en/UI/Angular/images/CapsLockDirective1.png new file mode 100644 index 0000000000..2f143d755f Binary files /dev/null and b/docs/en/UI/Angular/images/CapsLockDirective1.png differ diff --git a/docs/en/UI/Angular/images/CapsLockDirective2.png b/docs/en/UI/Angular/images/CapsLockDirective2.png new file mode 100644 index 0000000000..a46ad710f1 Binary files /dev/null and b/docs/en/UI/Angular/images/CapsLockDirective2.png differ diff --git a/docs/en/UI/Angular/images/showPasswordDirective1.png b/docs/en/UI/Angular/images/showPasswordDirective1.png new file mode 100644 index 0000000000..7b64be2b5f Binary files /dev/null and b/docs/en/UI/Angular/images/showPasswordDirective1.png differ diff --git a/docs/en/UI/Angular/images/showPasswordDirective2.png b/docs/en/UI/Angular/images/showPasswordDirective2.png new file mode 100644 index 0000000000..43199ffeaa Binary files /dev/null and b/docs/en/UI/Angular/images/showPasswordDirective2.png differ diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json index c6c07d9a7c..08046fa664 100644 --- a/docs/en/docs-nav.json +++ b/docs/en/docs-nav.json @@ -1522,6 +1522,10 @@ } ] }, + { + "text": "API Documentation", + "path": "{ApiDocumentationUrl}" + }, { "text": "Contribution Guide", "path": "Contribution/Index.md" diff --git a/docs/zh-Hans/Modules/Setting-Management.md b/docs/zh-Hans/Modules/Setting-Management.md index 242553c2c9..cf52d588a2 100644 --- a/docs/zh-Hans/Modules/Setting-Management.md +++ b/docs/zh-Hans/Modules/Setting-Management.md @@ -146,7 +146,8 @@ public class BookStoreSettingPageContributor : ISettingPageContributor new SettingPageGroup( "Volo.Abp.MySettingGroup", "MySettingGroup", - typeof(MySettingGroupViewComponent) + typeof(MySettingGroupViewComponent), + order : 1 ) ); @@ -209,7 +210,8 @@ public class BookStoreSettingComponentContributor : ISettingComponentContributor new SettingComponentGroup( "Volo.Abp.MySettingGroup", "MySettingGroup", - typeof(MySettingGroupComponent) + typeof(MySettingGroupComponent), + order : 1 ) ); diff --git a/framework/src/Volo.Abp.Core/Microsoft/Extensions/Hosting/AbpHostingHostBuilderExtensions.cs b/framework/src/Volo.Abp.Core/Microsoft/Extensions/Hosting/AbpHostingHostBuilderExtensions.cs index 767fa43f1d..09f6ed9bed 100644 --- a/framework/src/Volo.Abp.Core/Microsoft/Extensions/Hosting/AbpHostingHostBuilderExtensions.cs +++ b/framework/src/Volo.Abp.Core/Microsoft/Extensions/Hosting/AbpHostingHostBuilderExtensions.cs @@ -15,7 +15,7 @@ public static class AbpHostingHostBuilderExtensions return hostBuilder.ConfigureAppConfiguration((_, builder) => { builder.AddJsonFile( - path: AppSettingsSecretJsonPath, + path: path, optional: optional, reloadOnChange: reloadOnChange ); diff --git a/framework/src/Volo.Abp.Http.Client.IdentityModel.MauiBlazor/Volo/Abp/Http/Client/IdentityModel/MauiBlazor/IAbpMauiAccessTokenProvider.cs b/framework/src/Volo.Abp.Http.Client.IdentityModel.MauiBlazor/Volo/Abp/Http/Client/IdentityModel/MauiBlazor/IAbpMauiAccessTokenProvider.cs deleted file mode 100644 index 0c257b090c..0000000000 --- a/framework/src/Volo.Abp.Http.Client.IdentityModel.MauiBlazor/Volo/Abp/Http/Client/IdentityModel/MauiBlazor/IAbpMauiAccessTokenProvider.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System.Threading.Tasks; - -namespace Volo.Abp.Http.Client.IdentityModel.MauiBlazor; - -public interface IAbpMauiAccessTokenProvider -{ - Task GetAccessTokenAsync(); -} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Http.Client.IdentityModel.MauiBlazor/Volo/Abp/Http/Client/IdentityModel/MauiBlazor/MauiBlazorAbpAccessTokenProvider.cs b/framework/src/Volo.Abp.Http.Client.IdentityModel.MauiBlazor/Volo/Abp/Http/Client/IdentityModel/MauiBlazor/MauiBlazorAbpAccessTokenProvider.cs new file mode 100644 index 0000000000..8afbcbafed --- /dev/null +++ b/framework/src/Volo.Abp.Http.Client.IdentityModel.MauiBlazor/Volo/Abp/Http/Client/IdentityModel/MauiBlazor/MauiBlazorAbpAccessTokenProvider.cs @@ -0,0 +1,14 @@ +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Http.Client.Authentication; + +namespace Volo.Abp.Http.Client.IdentityModel.MauiBlazor; + +[Dependency(ReplaceServices = true)] +public class MauiBlazorAbpAccessTokenProvider : IAbpAccessTokenProvider, ITransientDependency +{ + public virtual Task GetTokenAsync() + { + return Task.FromResult(null as string); + } +} diff --git a/framework/src/Volo.Abp.Http.Client.IdentityModel.MauiBlazor/Volo/Abp/Http/Client/IdentityModel/MauiBlazor/MauiIBlazorIdentityModelRemoteServiceHttpClientAuthenticator.cs b/framework/src/Volo.Abp.Http.Client.IdentityModel.MauiBlazor/Volo/Abp/Http/Client/IdentityModel/MauiBlazor/MauiIBlazorIdentityModelRemoteServiceHttpClientAuthenticator.cs index ba36de1d77..b1277373fa 100644 --- a/framework/src/Volo.Abp.Http.Client.IdentityModel.MauiBlazor/Volo/Abp/Http/Client/IdentityModel/MauiBlazor/MauiIBlazorIdentityModelRemoteServiceHttpClientAuthenticator.cs +++ b/framework/src/Volo.Abp.Http.Client.IdentityModel.MauiBlazor/Volo/Abp/Http/Client/IdentityModel/MauiBlazor/MauiIBlazorIdentityModelRemoteServiceHttpClientAuthenticator.cs @@ -1,8 +1,5 @@ -using System; -using System.Threading.Tasks; +using System.Threading.Tasks; using IdentityModel.Client; -using JetBrains.Annotations; -using Microsoft.Extensions.DependencyInjection; using Volo.Abp.DependencyInjection; using Volo.Abp.Http.Client.Authentication; using Volo.Abp.IdentityModel; @@ -12,22 +9,21 @@ namespace Volo.Abp.Http.Client.IdentityModel.MauiBlazor; [Dependency(ReplaceServices = true)] public class MauiBlazorIdentityModelRemoteServiceHttpClientAuthenticator : IdentityModelRemoteServiceHttpClientAuthenticator { - [CanBeNull] - protected IAbpMauiAccessTokenProvider AbpMauiAccessTokenProvider { get; } + protected IAbpAccessTokenProvider AccessTokenProvider { get; } public MauiBlazorIdentityModelRemoteServiceHttpClientAuthenticator( IIdentityModelAuthenticationService identityModelAuthenticationService, - IServiceProvider serviceProvider) + IAbpAccessTokenProvider abpAccessTokenProvider) : base(identityModelAuthenticationService) { - AbpMauiAccessTokenProvider = serviceProvider.GetService(); + AccessTokenProvider = abpAccessTokenProvider; } public async override Task Authenticate(RemoteServiceHttpClientAuthenticateContext context) { if (context.RemoteService.GetUseCurrentAccessToken() != false) { - var accessToken = await GetAccessTokenFromAccessTokenProviderOrNullAsync(); + var accessToken = await AccessTokenProvider.GetTokenAsync(); if (accessToken != null) { context.Request.SetBearerToken(accessToken); @@ -37,14 +33,4 @@ public class MauiBlazorIdentityModelRemoteServiceHttpClientAuthenticator : Ident await base.Authenticate(context); } - - protected virtual async Task GetAccessTokenFromAccessTokenProviderOrNullAsync() - { - if (AbpMauiAccessTokenProvider == null) - { - return null; - } - - return await AbpMauiAccessTokenProvider.GetAccessTokenAsync(); - } } diff --git a/framework/src/Volo.Abp.Http.Client.IdentityModel.MauiBlazor/Volo/Abp/Http/Client/IdentityModel/MauiBlazor/NullAbpMauiAccessTokenProvider.cs b/framework/src/Volo.Abp.Http.Client.IdentityModel.MauiBlazor/Volo/Abp/Http/Client/IdentityModel/MauiBlazor/NullAbpMauiAccessTokenProvider.cs deleted file mode 100644 index ae6ecd949f..0000000000 --- a/framework/src/Volo.Abp.Http.Client.IdentityModel.MauiBlazor/Volo/Abp/Http/Client/IdentityModel/MauiBlazor/NullAbpMauiAccessTokenProvider.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; - -namespace Volo.Abp.Http.Client.IdentityModel.MauiBlazor; - -[Dependency(TryRegister = true)] -public class NullAbpMauiAccessTokenProvider : IAbpMauiAccessTokenProvider -{ - public Task GetAccessTokenAsync() - { - return Task.FromResult(null as string); - } -} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo/Abp/Http/Client/IdentityModel/Web/AbpHttpClientIdentityModelWebModule.cs b/framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo/Abp/Http/Client/IdentityModel/Web/AbpHttpClientIdentityModelWebModule.cs index 44959fbb82..1478193bf6 100644 --- a/framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo/Abp/Http/Client/IdentityModel/Web/AbpHttpClientIdentityModelWebModule.cs +++ b/framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo/Abp/Http/Client/IdentityModel/Web/AbpHttpClientIdentityModelWebModule.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Modularity; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Modularity; namespace Volo.Abp.Http.Client.IdentityModel.Web; @@ -7,5 +8,8 @@ namespace Volo.Abp.Http.Client.IdentityModel.Web; )] public class AbpHttpClientIdentityModelWebModule : AbpModule { - + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddHttpContextAccessor(); + } } diff --git a/framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo/Abp/Http/Client/IdentityModel/Web/HttpContextAbpAccessTokenProvider.cs b/framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo/Abp/Http/Client/IdentityModel/Web/HttpContextAbpAccessTokenProvider.cs new file mode 100644 index 0000000000..97d88bd3b0 --- /dev/null +++ b/framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo/Abp/Http/Client/IdentityModel/Web/HttpContextAbpAccessTokenProvider.cs @@ -0,0 +1,29 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Http; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Http.Client.Authentication; + +namespace Volo.Abp.Http.Client.IdentityModel.Web; + +[Dependency(ReplaceServices = true)] +public class HttpContextAbpAccessTokenProvider : IAbpAccessTokenProvider, ITransientDependency +{ + protected IHttpContextAccessor HttpContextAccessor { get; } + + public HttpContextAbpAccessTokenProvider(IHttpContextAccessor httpContextAccessor) + { + HttpContextAccessor = httpContextAccessor; + } + + public virtual async Task GetTokenAsync() + { + var httpContext = HttpContextAccessor?.HttpContext; + if (httpContext == null) + { + return null; + } + + return await httpContext.GetTokenAsync("access_token"); + } +} diff --git a/framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo/Abp/Http/Client/IdentityModel/Web/HttpContextIdentityModelRemoteServiceHttpClientAuthenticator.cs b/framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo/Abp/Http/Client/IdentityModel/Web/HttpContextIdentityModelRemoteServiceHttpClientAuthenticator.cs index 6ae44a0943..364134348b 100644 --- a/framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo/Abp/Http/Client/IdentityModel/Web/HttpContextIdentityModelRemoteServiceHttpClientAuthenticator.cs +++ b/framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo/Abp/Http/Client/IdentityModel/Web/HttpContextIdentityModelRemoteServiceHttpClientAuthenticator.cs @@ -1,7 +1,5 @@ using System.Threading.Tasks; using IdentityModel.Client; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Http; using Volo.Abp.DependencyInjection; using Volo.Abp.Http.Client.Authentication; using Volo.Abp.IdentityModel; @@ -11,19 +9,21 @@ namespace Volo.Abp.Http.Client.IdentityModel.Web; [Dependency(ReplaceServices = true)] public class HttpContextIdentityModelRemoteServiceHttpClientAuthenticator : IdentityModelRemoteServiceHttpClientAuthenticator { - public IHttpContextAccessor HttpContextAccessor { get; set; } + protected IAbpAccessTokenProvider AccessTokenProvider { get; } public HttpContextIdentityModelRemoteServiceHttpClientAuthenticator( - IIdentityModelAuthenticationService identityModelAuthenticationService) + IIdentityModelAuthenticationService identityModelAuthenticationService, + IAbpAccessTokenProvider accessTokenProvider) : base(identityModelAuthenticationService) { + AccessTokenProvider = accessTokenProvider; } - public override async Task Authenticate(RemoteServiceHttpClientAuthenticateContext context) + public async override Task Authenticate(RemoteServiceHttpClientAuthenticateContext context) { if (context.RemoteService.GetUseCurrentAccessToken() != false) { - var accessToken = await GetAccessTokenFromHttpContextOrNullAsync(); + var accessToken = await AccessTokenProvider.GetTokenAsync(); if (accessToken != null) { context.Request.SetBearerToken(accessToken); @@ -33,15 +33,4 @@ public class HttpContextIdentityModelRemoteServiceHttpClientAuthenticator : Iden await base.Authenticate(context); } - - protected virtual async Task GetAccessTokenFromHttpContextOrNullAsync() - { - var httpContext = HttpContextAccessor?.HttpContext; - if (httpContext == null) - { - return null; - } - - return await httpContext.GetTokenAsync("access_token"); - } } diff --git a/framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly/Volo/Abp/Http/Client/IdentityModel/WebAssembly/AccessTokenProviderIdentityModelRemoteServiceHttpClientAuthenticator.cs b/framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly/Volo/Abp/Http/Client/IdentityModel/WebAssembly/AccessTokenProviderIdentityModelRemoteServiceHttpClientAuthenticator.cs index 846cc6f3a3..c16317e376 100644 --- a/framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly/Volo/Abp/Http/Client/IdentityModel/WebAssembly/AccessTokenProviderIdentityModelRemoteServiceHttpClientAuthenticator.cs +++ b/framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly/Volo/Abp/Http/Client/IdentityModel/WebAssembly/AccessTokenProviderIdentityModelRemoteServiceHttpClientAuthenticator.cs @@ -1,9 +1,5 @@ -using System; -using System.Threading.Tasks; +using System.Threading.Tasks; using IdentityModel.Client; -using JetBrains.Annotations; -using Microsoft.AspNetCore.Components.WebAssembly.Authentication; -using Microsoft.Extensions.DependencyInjection; using Volo.Abp.DependencyInjection; using Volo.Abp.Http.Client.Authentication; using Volo.Abp.IdentityModel; @@ -14,22 +10,21 @@ namespace Volo.Abp.Http.Client.IdentityModel.WebAssembly; public class AccessTokenProviderIdentityModelRemoteServiceHttpClientAuthenticator : IdentityModelRemoteServiceHttpClientAuthenticator { - [CanBeNull] - protected IAccessTokenProvider AccessTokenProvider { get; } + protected IAbpAccessTokenProvider AccessTokenProvider { get; } public AccessTokenProviderIdentityModelRemoteServiceHttpClientAuthenticator( IIdentityModelAuthenticationService identityModelAuthenticationService, - IServiceProvider serviceProvider) + IAbpAccessTokenProvider accessTokenProvider) : base(identityModelAuthenticationService) { - AccessTokenProvider = serviceProvider.GetService(); + AccessTokenProvider = accessTokenProvider; } - public override async Task Authenticate(RemoteServiceHttpClientAuthenticateContext context) + public async override Task Authenticate(RemoteServiceHttpClientAuthenticateContext context) { if (context.RemoteService.GetUseCurrentAccessToken() != false) { - var accessToken = await GetAccessTokenFromAccessTokenProviderOrNullAsync(); + var accessToken = await AccessTokenProvider.GetTokenAsync(); if (accessToken != null) { context.Request.SetBearerToken(accessToken); @@ -39,21 +34,4 @@ public class AccessTokenProviderIdentityModelRemoteServiceHttpClientAuthenticato await base.Authenticate(context); } - - protected virtual async Task GetAccessTokenFromAccessTokenProviderOrNullAsync() - { - if (AccessTokenProvider == null) - { - return null; - } - - var result = await AccessTokenProvider.RequestAccessToken(); - if (result.Status != AccessTokenResultStatus.Success) - { - return null; - } - - result.TryGetToken(out var token); - return token.Value; - } } diff --git a/framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly/Volo/Abp/Http/Client/IdentityModel/WebAssembly/WebAssemblyAbpAccessTokenProvider.cs b/framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly/Volo/Abp/Http/Client/IdentityModel/WebAssembly/WebAssemblyAbpAccessTokenProvider.cs new file mode 100644 index 0000000000..d0a68cdb7c --- /dev/null +++ b/framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly/Volo/Abp/Http/Client/IdentityModel/WebAssembly/WebAssemblyAbpAccessTokenProvider.cs @@ -0,0 +1,34 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components.WebAssembly.Authentication; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Http.Client.Authentication; + +namespace Volo.Abp.Http.Client.IdentityModel.WebAssembly; + +[Dependency(ReplaceServices = true)] +public class WebAssemblyAbpAccessTokenProvider : IAbpAccessTokenProvider, ITransientDependency +{ + protected IAccessTokenProvider AccessTokenProvider { get; } + + public WebAssemblyAbpAccessTokenProvider(IAccessTokenProvider accessTokenProvider) + { + AccessTokenProvider = accessTokenProvider; + } + + public virtual async Task GetTokenAsync() + { + if (AccessTokenProvider == null) + { + return null; + } + + var result = await AccessTokenProvider.RequestAccessToken(); + if (result.Status != AccessTokenResultStatus.Success) + { + return null; + } + + result.TryGetToken(out var token); + return token.Value; + } +} diff --git a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Authentication/IAbpAccessTokenProvider.cs b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Authentication/IAbpAccessTokenProvider.cs new file mode 100644 index 0000000000..a4e9e650e3 --- /dev/null +++ b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Authentication/IAbpAccessTokenProvider.cs @@ -0,0 +1,8 @@ +using System.Threading.Tasks; + +namespace Volo.Abp.Http.Client.Authentication; + +public interface IAbpAccessTokenProvider +{ + Task GetTokenAsync(); +} diff --git a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Authentication/NullAbpAccessTokenProvider.cs b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Authentication/NullAbpAccessTokenProvider.cs new file mode 100644 index 0000000000..6bd7e6344b --- /dev/null +++ b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Authentication/NullAbpAccessTokenProvider.cs @@ -0,0 +1,12 @@ +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.Http.Client.Authentication; + +public class NullAbpAccessTokenProvider : IAbpAccessTokenProvider, ITransientDependency +{ + public Task GetTokenAsync() + { + return Task.FromResult(null as string); + } +} diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/DemoAppSharedModule.cs b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/DemoAppSharedModule.cs index 193e87b528..ad002a5e18 100644 --- a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/DemoAppSharedModule.cs +++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/DemoAppSharedModule.cs @@ -5,7 +5,7 @@ using Volo.Abp.Modularity; namespace Volo.Abp.BackgroundJobs.DemoApp.Shared { [DependsOn( - typeof(AbpBackgroundJobsAbstractionsModule) + typeof(AbpBackgroundJobsModule) )] public class DemoAppSharedModule : AbpModule { diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Volo.Abp.BackgroundJobs.DemoApp.Shared.csproj b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Volo.Abp.BackgroundJobs.DemoApp.Shared.csproj index e6a08dbd02..d8ff12e3f8 100644 --- a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Volo.Abp.BackgroundJobs.DemoApp.Shared.csproj +++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Volo.Abp.BackgroundJobs.DemoApp.Shared.csproj @@ -8,7 +8,7 @@ - + diff --git a/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs b/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs index 93d8a52ee7..974f81a201 100644 --- a/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs +++ b/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs @@ -16,7 +16,8 @@ public class AbpIdentityAspNetCoreModule : AbpModule builder .AddDefaultTokenProviders() .AddTokenProvider(LinkUserTokenProviderConsts.LinkUserTokenProviderName) - .AddSignInManager(); + .AddSignInManager() + .AddUserValidator(); }); } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ar.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ar.json index 490bd611df..39c55dfb7c 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ar.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ar.json @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "اسم الدور '{0}' غير صالح.", "Volo.Abp.Identity:InvalidToken": "غير صالح token.", "Volo.Abp.Identity:InvalidUserName": "اسم المستخدم '{0}' غير صالح ، يمكن أن يحتوي على أحرف أو أرقام فقط.", + "InvalidUserName": "لااسم المستخدم '{0}' غير صالح .", "Volo.Abp.Identity:LoginAlreadyAssociated": "يوجد مستخدم لديه معلومات تسجيل الدخول هذه بالفعل.", "Volo.Abp.Identity:PasswordMismatch": "كلمة مرور غير صحيحة.", "Volo.Abp.Identity:PasswordRequiresDigit": "يجب أن تحتوي كلمات المرور على رقم واحد على الأقل ('0' - '9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/cs.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/cs.json index 7f2ddde421..87d0b79066 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/cs.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/cs.json @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "Role '{0}' je neplatná.", "Volo.Abp.Identity:InvalidToken": "Neplatný token.", "Volo.Abp.Identity:InvalidUserName": "Uživatelské jméno '{0}' je neplatné, může obsahovat pouze písmena a číslice.", + "InvalidUserName": "Uživatelské jméno '{0}' je neplatné.", "Volo.Abp.Identity:LoginAlreadyAssociated": "Uživatel s tímto přihlášením již existuje.", "Volo.Abp.Identity:PasswordMismatch": "Chybné heslo.", "Volo.Abp.Identity:PasswordRequiresDigit": "Hesla musí obsahovat alespoň jednu číslici ('0'-'9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/de.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/de.json index 69f2e9e9b2..841752f211 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/de.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/de.json @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "Der Rollenname '{0}' ist ungültig.", "Volo.Abp.Identity:InvalidToken": "Ungültiger Token.", "Volo.Abp.Identity:InvalidUserName": "Der Benutzername '{0}' ist ungültig und darf nur Buchstaben oder Ziffern enthalten.", + "InvalidUserName": "Der Benutzername '{0}' ist ungültig.", "Volo.Abp.Identity:LoginAlreadyAssociated": "Ein Benutzer mit diesem Login existiert bereits.", "Volo.Abp.Identity:PasswordMismatch": "Falsches Passwort.", "Volo.Abp.Identity:PasswordRequiresDigit": "Passwörter müssen mindestens eine Ziffer haben ('0' - '9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/el.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/el.json index 765d85ce09..9316a29d39 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/el.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/el.json @@ -47,6 +47,7 @@ "Volo.Abp.Identity:InvalidRoleName": "Το όνομα ρόλου '{0}' δεν είναι έγκυρο.", "Volo.Abp.Identity:InvalidToken": "Μη έγκυρο διακριτικό.", "Volo.Abp.Identity:InvalidUserName": "Το όνομα χρήστη '{0}' δεν είναι έγκυρο, μπορεί να περιέχει μόνο γράμματα ή ψηφία.", + "InvalidUserName": "Το όνομα χρήστη '{0}' δεν είναι έγκυρο.", "Volo.Abp.Identity:LoginAlreadyAssociated": "Ένας χρήστης με αυτήν τη σύνδεση υπάρχει ήδη.", "Volo.Abp.Identity:PasswordMismatch": "Λάθος κωδικός.", "Volo.Abp.Identity:PasswordRequiresDigit": "Οι κωδικοί πρόσβασης πρέπει να έχουν τουλάχιστον ένα ψηφίο ('0'-'9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en-GB.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en-GB.json index adebfa33e8..15e534ea67 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en-GB.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en-GB.json @@ -47,6 +47,7 @@ "Volo.Abp.Identity:InvalidRoleName": "Role name '{0}' is invalid.", "Volo.Abp.Identity:InvalidToken": "Invalid token.", "Volo.Abp.Identity:InvalidUserName": "Username '{0}' is invalid, it should only contain letters or digits.", + "InvalidUserName": "Username '{0}' is invalid.", "Volo.Abp.Identity:LoginAlreadyAssociated": "A user with this login already exists.", "Volo.Abp.Identity:PasswordMismatch": "Incorrect password.", "Volo.Abp.Identity:PasswordRequiresDigit": "Passwords must have at least one digit ('0'-'9').", 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 2446650c60..8d0ab1fe19 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 @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "Role name '{0}' is invalid.", "Volo.Abp.Identity:InvalidToken": "Invalid token.", "Volo.Abp.Identity:InvalidUserName": "Username '{0}' is invalid, can only contain letters or digits.", + "InvalidUserName": "Username '{0}' is invalid.", "Volo.Abp.Identity:LoginAlreadyAssociated": "A user with this login already exists.", "Volo.Abp.Identity:PasswordMismatch": "Incorrect password.", "Volo.Abp.Identity:PasswordRequiresDigit": "Passwords must have at least one digit ('0'-'9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/es.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/es.json index 06c279ec73..c70078845c 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/es.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/es.json @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "El nombre de rol '{0}' no es válido.", "Volo.Abp.Identity:InvalidToken": "token no válido", "Volo.Abp.Identity:InvalidUserName": "Nombre de usuario '{0}' no es válido. Sólo puede contener letras o dígitos", + "InvalidUserName": "Nombre de usuario '{0}' no es válido.", "Volo.Abp.Identity:LoginAlreadyAssociated": "Usuario con este inicio de sesión en uso.", "Volo.Abp.Identity:PasswordMismatch": "Contraseña incorrecta.", "Volo.Abp.Identity:PasswordRequiresDigit": "Contraseñas deben tener al menos un dígito ('0'-'9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fa.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fa.json index 7a89cebc87..f349f080af 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fa.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fa.json @@ -47,6 +47,7 @@ "Volo.Abp.Identity:InvalidRoleName": "عنوان نقش/وظیفه {0} نامعتبر است.", "Volo.Abp.Identity:InvalidToken": "گذرواژه وارد شده معتبر نیست.", "Volo.Abp.Identity:InvalidUserName": "نام کاربری '{0}' نامعتبر است، نام کاربری فقط می تواند شامل حروف یا ارقام باشد.", + "InvalidUserName": "ام کاربری '{0}' نامعتبر است", "Volo.Abp.Identity:LoginAlreadyAssociated": "یک کاربر با این نام کاربری از قبل موجود می باشد.", "Volo.Abp.Identity:PasswordMismatch": "گذرواژه اشتباه است.", "Volo.Abp.Identity:PasswordRequiresDigit": "گذرواژه ها باید حداقل یک رقم داشته باشند ('0'-'9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fi.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fi.json index d74257414a..6b133481e7 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fi.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fi.json @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "Roolin nimi {0} on virheellinen.", "Volo.Abp.Identity:InvalidToken": "Virheellinen tunnus.", "Volo.Abp.Identity:InvalidUserName": "Käyttäjätunnus {0} on virheellinen, voi sisältää vain kirjaimia tai numeroita.", + "InvalidUserName": "Käyttäjätunnus {0} on virheellinen.", "Volo.Abp.Identity:LoginAlreadyAssociated": "Käyttäjä, jolla on tämä sisäänkirjautuminen, on jo olemassa.", "Volo.Abp.Identity:PasswordMismatch": "Väärä salasana.", "Volo.Abp.Identity:PasswordRequiresDigit": "Salasanoissa on oltava vähintään yksi numero ('0'-'9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fr.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fr.json index 80a5f90a10..c9d1bfba7b 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fr.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fr.json @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "Le nom de rôle '{0}' n’est pas valide.", "Volo.Abp.Identity:InvalidToken": "Jeton non valide.", "Volo.Abp.Identity:InvalidUserName": "Le nom d’utilisateur '{0}' n’est pas valide, ne peut contenir que des lettres ou des chiffres.", + "InvalidUserName": "Le nom d’utilisateur '{0}' n’est pas valide.", "Volo.Abp.Identity:LoginAlreadyAssociated": "Un utilisateur avec cette connexion existe déjà.", "Volo.Abp.Identity:PasswordMismatch": "Mot de passe incorrect.", "Volo.Abp.Identity:PasswordRequiresDigit": "Les mots de passe doivent avoir au moins un chiffre ('0'-'9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hi.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hi.json index e01e4c8e25..7155c3bf58 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hi.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hi.json @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "भूमिका नाम '{0}' अमान्य है।", "Volo.Abp.Identity:InvalidToken": "अमान्य टोकन।", "Volo.Abp.Identity:InvalidUserName": "उपयोगकर्ता नाम '{0}' अमान्य है, इसमें केवल अक्षर या अंक हो सकते हैं।", + "InvalidUserName": "उपयोगकर्ता नाम '{0}' अमान्य है", "Volo.Abp.Identity:LoginAlreadyAssociated": "इस लॉगिन वाला उपयोगकर्ता पहले से मौजूद है।", "Volo.Abp.Identity:PasswordMismatch": "गलत पासवर्ड।", "Volo.Abp.Identity:PasswordRequiresDigit": "पासवर्ड में कम से कम एक अंक ('0'-'9') होना चाहिए।", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hr.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hr.json index a31715fc16..cdea4c02f5 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hr.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hr.json @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "Naziv uloge '{0}' nije valjan.", "Volo.Abp.Identity:InvalidToken": "Pogrešan token.", "Volo.Abp.Identity:InvalidUserName": "Korisničko ime '{0}' nije važeće, može sadržavati samo slova ili znamenke.", + "InvalidUserName": "Korisničko ime '{0}' nije važeće.", "Volo.Abp.Identity:LoginAlreadyAssociated": "Korisnik s ovom prijavom već postoji.", "Volo.Abp.Identity:PasswordMismatch": "Netočna lozinka.", "Volo.Abp.Identity:PasswordRequiresDigit": "Lozinke moraju imati najmanje jednu znamenku ('0'-'9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hu.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hu.json index 8c658c9e89..fc72ed1e0f 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hu.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hu.json @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "'{0}' szerepkör név érvénytelen.", "Volo.Abp.Identity:InvalidToken": "Érvénytelen token.", "Volo.Abp.Identity:InvalidUserName": "'{0}' felhasználónév érvénytelen, csak betűket és számokat tartalmazhat.", + "InvalidUserName": "'{0}' felhasználónév érvénytelen.", "Volo.Abp.Identity:LoginAlreadyAssociated": "Az ilyen bejelentkezéssel rendelkező felhasználó már létezik.", "Volo.Abp.Identity:PasswordMismatch": "Érvénytelen jelszó.", "Volo.Abp.Identity:PasswordRequiresDigit": "A jelszavaknak legalább egy számjegyet kell rendelkezniük ('0'-'9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/is.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/is.json index c0bb4af19a..a30d47f4c0 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/is.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/is.json @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "Hlutverkanafnið '{0}' er ógilt.", "Volo.Abp.Identity:InvalidToken": "Ógilt token.", "Volo.Abp.Identity:InvalidUserName": "Notandanafnið '{0}' er ógilt, getur aðeins innihaldið bókstafi eða tölustafi.", + "InvalidUserName": "Notandanafnið '{0}' er ógilt.", "Volo.Abp.Identity:LoginAlreadyAssociated": "Notandi með þessa innskráningu er þegar til.", "Volo.Abp.Identity:PasswordMismatch": "Rangt lykilorð.", "Volo.Abp.Identity:PasswordRequiresDigit": "Lykilorð verða að hafa að minnsta kosti einn staf ('0'-'9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/it.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/it.json index 513def4b52..67a0cbeb36 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/it.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/it.json @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "Il nome del ruolo '{0}' non è valido.", "Volo.Abp.Identity:InvalidToken": "Token non valido.", "Volo.Abp.Identity:InvalidUserName": "Il nome utente '{0}' non è valido, può contenere solo lettere o cifre.", + "InvalidUserName": "Il nome utente '{0}' non è valido.", "Volo.Abp.Identity:LoginAlreadyAssociated": "Esiste già un utente con questo account.", "Volo.Abp.Identity:PasswordMismatch": "Password errata.", "Volo.Abp.Identity:PasswordRequiresDigit": "La password deve contenere almeno una cifra ('0'-'9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/nl.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/nl.json index 472935418b..139fa50107 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/nl.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/nl.json @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "Rol naam '{0}' is ongeldig.", "Volo.Abp.Identity:InvalidToken": "Ongeldig token.", "Volo.Abp.Identity:InvalidUserName": "Gebruikersnaam '{0}' is ongeldig, mag alleen letters of cijfers bevatten.", + "InvalidUserName": "Gebruikersnaam '{0}' is ongeldig.", "Volo.Abp.Identity:LoginAlreadyAssociated": "Er bestaat al een gebruiker met deze login.", "Volo.Abp.Identity:PasswordMismatch": "Incorrect wachtwoord.", "Volo.Abp.Identity:PasswordRequiresDigit": "Wachtwoorden moeten minimaal één cijfer bevatten ('0' - '9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pl-PL.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pl-PL.json index 377c792ddf..dabf2655c4 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pl-PL.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pl-PL.json @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "Rola '{0}' jest niepoprawna.", "Volo.Abp.Identity:InvalidToken": "Niepoprawny token.", "Volo.Abp.Identity:InvalidUserName": "Nazwa użytkownika '{0}' jest niepoprawna, może zawierać tylko litery i cyfry.", + "InvalidUserName": "Nazwa użytkownika '{0}' jest niepoprawna.", "Volo.Abp.Identity:LoginAlreadyAssociated": "Użytkownik o tym loginie już istnieje.", "Volo.Abp.Identity:PasswordMismatch": "Niepoprawne hasło.", "Volo.Abp.Identity:PasswordRequiresDigit": "Hasło musi zawierać przynajmniej jedną cyfrę ('0'-'9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pt-BR.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pt-BR.json index c8807d2792..999a9f19bd 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pt-BR.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pt-BR.json @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "Perfil '{0}' inválido.", "Volo.Abp.Identity:InvalidToken": "Token inválido.", "Volo.Abp.Identity:InvalidUserName": "Usuário '{0}' é inválido, somente pode conter letras ou números.", + "InvalidUserName": "Usuário '{0}' é inválido.", "Volo.Abp.Identity:LoginAlreadyAssociated": "Um usuário com este login já existe.", "Volo.Abp.Identity:PasswordMismatch": "Senha incorreta.", "Volo.Abp.Identity:PasswordRequiresDigit": "Senhas devem possuir pelo menos um dígito ('0'-'9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ro-RO.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ro-RO.json index d86eb4f1fa..573331d4f3 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ro-RO.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ro-RO.json @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "Numele de rol '{0}' este invalid.", "Volo.Abp.Identity:InvalidToken": "Invalid token.", "Volo.Abp.Identity:InvalidUserName": "Numele de utilizator '{0}' este invalid, poate conţine doar litere şi cifre.", + "InvalidUserName": "Numele de utilizator '{0}' este invalid.", "Volo.Abp.Identity:LoginAlreadyAssociated": "Un utilizator cu această autentificare există deja.", "Volo.Abp.Identity:PasswordMismatch": "Parolă incorectă.", "Volo.Abp.Identity:PasswordRequiresDigit": "Parolele trebuie să conţină cel puţin o cifră ('0'-'9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ru.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ru.json index 73fd937af0..7bd8da5955 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ru.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ru.json @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "Имя роли '{0}' недопустимо.", "Volo.Abp.Identity:InvalidToken": "Недопустимый маркер.", "Volo.Abp.Identity:InvalidUserName": "Имя пользователя '{0}' недопустимо и может содержать только буквы или цифры.", + "InvalidUserName": "Имя пользователя '{0}' недопустимо.", "Volo.Abp.Identity:LoginAlreadyAssociated": "Пользователь с таким логином уже существует.", "Volo.Abp.Identity:PasswordMismatch": "Неверный пароль.", "Volo.Abp.Identity:PasswordRequiresDigit": "Пароль должен содержать по крайней мере одну цифру.", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sk.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sk.json index 83eb3850ad..520377210d 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sk.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sk.json @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "Názov roly '{0}' je neplatný.", "Volo.Abp.Identity:InvalidToken": "Neplatný token.", "Volo.Abp.Identity:InvalidUserName": "Používateľské meno '{0}' je neplatné, môže obsahovať len písmená alebo číslice.", + "InvalidUserName": "Používateľské meno '{0}' je neplatné.", "Volo.Abp.Identity:LoginAlreadyAssociated": "Používateľ s týmto prihlasovacím menom už existuje.", "Volo.Abp.Identity:PasswordMismatch": "Nesprávne heslo.", "Volo.Abp.Identity:PasswordRequiresDigit": "Heslá musia obsahovať aspoň jednu číslicu ('0'-'9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sl.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sl.json index caa60a2d71..0fec5bbd4d 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sl.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sl.json @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "Naziv vloge '{0}' ni veljaven.", "Volo.Abp.Identity:InvalidToken": "Neveljaven žeton.", "Volo.Abp.Identity:InvalidUserName": "Uporabniško ime '{0}' ni veljavno, vsebuje lahko le črke in številke.", + "InvalidUserName": "Uporabniško ime '{0}' ni veljavno.", "Volo.Abp.Identity:LoginAlreadyAssociated": "Uporabnik s to prijavo že obstaja.", "Volo.Abp.Identity:PasswordMismatch": "Nepravilno geslo.", "Volo.Abp.Identity:PasswordRequiresDigit": "Gesla morajo imeti vsaj eno številko ('0'-'9').", 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 6d19fea5ea..e6614025c1 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 @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "'{0}' rol ismi geçersizdir.", "Volo.Abp.Identity:InvalidToken": "Geçersiz token.", "Volo.Abp.Identity:InvalidUserName": "'{0}' kullanıcı adı geçersiz, sadece harf ve rakamlardan oluşmalı.", + "InvalidUserName": "'{0}' kullanıcı adı geçersiz.", "Volo.Abp.Identity:LoginAlreadyAssociated": "Bu giriş bilgilerine sahip bir kullanıcı zaten var.", "Volo.Abp.Identity:PasswordMismatch": "Hatalı şifre.", "Volo.Abp.Identity:PasswordRequiresDigit": "Şifre en az bir sayı içermeli ('0'-'9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/vi.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/vi.json index 05dbe248a0..c649637b4d 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/vi.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/vi.json @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "Tên người dùng '{0}' Không hợp lệ.", "Volo.Abp.Identity:InvalidToken": "Token không hợp lệ.", "Volo.Abp.Identity:InvalidUserName": "Tên người dùng '{0}' không hợp lệ, chỉ có thể chứa chữ cái hoặc chữ số.", + "InvalidUserName": "Tên người dùng '{0}' không hợp lệ.", "Volo.Abp.Identity:LoginAlreadyAssociated": "Một người dùng có thông tin đăng nhập này đã tồn tại.", "Volo.Abp.Identity:PasswordMismatch": "Mật khẩu không đúng.", "Volo.Abp.Identity:PasswordRequiresDigit": "Mật khẩu phải có ít nhất một chữ số ('0'-'9').", 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 095f5cef2f..165ba09b41 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 @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "角色名 '{0}' 无效.", "Volo.Abp.Identity:InvalidToken": "token无效.", "Volo.Abp.Identity:InvalidUserName": "用户名 '{0}' 无效, 只能包含字母或数字.", + "InvalidUserName": "用户名 '{0}' 无效.", "Volo.Abp.Identity:LoginAlreadyAssociated": "此登录名的用户已存在.", "Volo.Abp.Identity:PasswordMismatch": "密码错误.", "Volo.Abp.Identity:PasswordRequiresDigit": "密码至少包含一位数字 ('0'-'9').", 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 936ad985f6..d12c44890a 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 @@ -48,6 +48,7 @@ "Volo.Abp.Identity:InvalidRoleName": "角色名 '{0}' 無效.", "Volo.Abp.Identity:InvalidToken": "token無效.", "Volo.Abp.Identity:InvalidUserName": "使用者名稱 '{0}' 無效, 只能包含字母或數字.", + "InvalidUserName": "使用者名稱 '{0}' 無效.", "Volo.Abp.Identity:LoginAlreadyAssociated": "此登入名的使用者已存在.", "Volo.Abp.Identity:PasswordMismatch": "密碼錯誤.", "Volo.Abp.Identity:PasswordRequiresDigit": "密碼至少包含一位數字 ('0'-'9').", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityUserValidator.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityUserValidator.cs new file mode 100644 index 0000000000..c7507c6e36 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityUserValidator.cs @@ -0,0 +1,48 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Identity; +using Microsoft.Extensions.Localization; +using Volo.Abp.Identity.Localization; + +namespace Volo.Abp.Identity +{ + public class AbpIdentityUserValidator : IUserValidator + { + protected IStringLocalizer Localizer { get; } + + public AbpIdentityUserValidator(IStringLocalizer localizer) + { + Localizer = localizer; + } + + public virtual async Task ValidateAsync(UserManager manager, IdentityUser user) + { + var describer = new IdentityErrorDescriber(); + + Check.NotNull(manager, nameof(manager)); + Check.NotNull(user, nameof(user)); + + var errors = new List(); + + var userName = await manager.GetUserNameAsync(user); + if (userName == null) + { + errors.Add(describer.InvalidUserName(null)); + } + else + { + var owner = await manager.FindByEmailAsync(userName); + if (owner != null && !string.Equals(await manager.GetUserIdAsync(owner), await manager.GetUserIdAsync(user))) + { + errors.Add(new IdentityError + { + Code = "InvalidUserName", + Description = Localizer["InvalidUserName", userName] + }); + } + } + + return errors.Count > 0 ? IdentityResult.Failed(errors.ToArray()) : IdentityResult.Success; + } + } +} diff --git a/modules/identity/test/Volo.Abp.Identity.AspNetCore.Tests/Volo/Abp/Identity/AspNetCore/AbpIdentityUserValidator_Tests.cs b/modules/identity/test/Volo.Abp.Identity.AspNetCore.Tests/Volo/Abp/Identity/AspNetCore/AbpIdentityUserValidator_Tests.cs new file mode 100644 index 0000000000..ef9cfb53d3 --- /dev/null +++ b/modules/identity/test/Volo.Abp.Identity.AspNetCore.Tests/Volo/Abp/Identity/AspNetCore/AbpIdentityUserValidator_Tests.cs @@ -0,0 +1,36 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.Extensions.Localization; +using Shouldly; +using Volo.Abp.Identity.Localization; +using Xunit; + +namespace Volo.Abp.Identity.AspNetCore; + +public class AbpIdentityUserValidator_Tests : AbpIdentityAspNetCoreTestBase +{ + private readonly IdentityUserManager _identityUserManager; + private readonly IStringLocalizer Localizer; + + public AbpIdentityUserValidator_Tests() + { + _identityUserManager = GetRequiredService(); + Localizer = GetRequiredService>(); + } + + [Fact] + public async Task Can_Not_Use_Another_Users_Email_As_Your_Username_Test() + { + var user1 = new IdentityUser(Guid.NewGuid(), "user1", "user1@volosoft.com"); + var identityResult = await _identityUserManager.CreateAsync(user1); + identityResult.Succeeded.ShouldBeTrue(); + + var user2 = new IdentityUser(Guid.NewGuid(), "user1@volosoft.com", "user2@volosoft.com"); + identityResult = await _identityUserManager.CreateAsync(user2); + identityResult.Succeeded.ShouldBeFalse(); + identityResult.Errors.Count().ShouldBe(1); + identityResult.Errors.First().Code.ShouldBe("InvalidUserName"); + identityResult.Errors.First().Description.ShouldBe(Localizer["InvalidUserName", "user1@volosoft.com"]); + } +} diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/SettingManagement.razor.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/SettingManagement.razor.cs index 1422d67873..47a956a028 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/SettingManagement.razor.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/SettingManagement.razor.cs @@ -39,7 +39,7 @@ public partial class SettingManagement { await contributor.ConfigureAsync(SettingComponentCreationContext); } - + SettingComponentCreationContext.Normalize(); SettingItemRenders.Clear(); SelectedGroup = GetNormalizedString(SettingComponentCreationContext.Groups.First().Id); diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingComponentCreationContext.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingComponentCreationContext.cs index dfba0564f2..390110430c 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingComponentCreationContext.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingComponentCreationContext.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Volo.Abp.DependencyInjection; namespace Volo.Abp.SettingManagement.Blazor; @@ -8,7 +9,7 @@ public class SettingComponentCreationContext : IServiceProviderAccessor { public IServiceProvider ServiceProvider { get; } - public List Groups { get; } + public List Groups { get; private set; } public SettingComponentCreationContext(IServiceProvider serviceProvider) { @@ -16,4 +17,14 @@ public class SettingComponentCreationContext : IServiceProviderAccessor Groups = new List(); } + + public void Normalize() + { + Order(); + } + + private void Order() + { + Groups = Groups.OrderBy(item => item.Order).ThenBy(item => item.DisplayName).ToList(); + } } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingComponentGroup.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingComponentGroup.cs index bf4bbf2a22..0577f38b76 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingComponentGroup.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingComponentGroup.cs @@ -5,6 +5,8 @@ namespace Volo.Abp.SettingManagement.Blazor; public class SettingComponentGroup { + public const int DefaultOrder = 1000; + public string Id { get => _id; set => _id = Check.NotNullOrWhiteSpace(value, nameof(Id)); @@ -24,12 +26,15 @@ public class SettingComponentGroup private Type _componentType; public object Parameter { get; set; } + + public int Order { get; set; } - public SettingComponentGroup([NotNull] string id, [NotNull] string displayName, [NotNull] Type componentType, object parameter = null) + public SettingComponentGroup([NotNull] string id, [NotNull] string displayName, [NotNull] Type componentType, object parameter = null, int order = DefaultOrder) { Id = id; DisplayName = displayName; ComponentType = componentType; Parameter = parameter; + Order = order; } } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageContributorManager.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageContributorManager.cs index 9b08236cae..83f5d53fa5 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageContributorManager.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageContributorManager.cs @@ -37,6 +37,7 @@ public class SettingPageContributorManager : IScopedDependency { await contributor.ConfigureAsync(context); } + context.Normalize(); return context; } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageCreationContext.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageCreationContext.cs index c929fef16d..d620ced0b9 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageCreationContext.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageCreationContext.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Volo.Abp.DependencyInjection; namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement; @@ -8,7 +9,7 @@ public class SettingPageCreationContext : IServiceProviderAccessor { public IServiceProvider ServiceProvider { get; } - public List Groups { get; } + public List Groups { get; private set; } public SettingPageCreationContext(IServiceProvider serviceProvider) { @@ -16,4 +17,14 @@ public class SettingPageCreationContext : IServiceProviderAccessor Groups = new List(); } + + public void Normalize() + { + Order(); + } + + private void Order() + { + Groups = Groups.OrderBy(item => item.Order).ThenBy(item => item.DisplayName).ToList(); + } } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageGroup.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageGroup.cs index 2dbc6eb4de..65aceb554c 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageGroup.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageGroup.cs @@ -5,6 +5,8 @@ namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement; public class SettingPageGroup { + public const int DefaultOrder = 1000; + public string Id { get => _id; set => _id = Check.NotNullOrWhiteSpace(value, nameof(Id)); @@ -24,12 +26,15 @@ public class SettingPageGroup private Type _componentType; public object Parameter { get; set; } + + public int Order { get; set; } - public SettingPageGroup([NotNull] string id, [NotNull] string displayName, [NotNull] Type componentType, object parameter = null) + public SettingPageGroup([NotNull] string id, [NotNull] string displayName, [NotNull] Type componentType, object parameter = null, int order = DefaultOrder) { Id = id; DisplayName = displayName; ComponentType = componentType; Parameter = parameter; + Order = order; } } diff --git a/npm/ng-packs/packages/core/src/lib/core.module.ts b/npm/ng-packs/packages/core/src/lib/core.module.ts index c2d497ae7b..c4f7c78fa7 100644 --- a/npm/ng-packs/packages/core/src/lib/core.module.ts +++ b/npm/ng-packs/packages/core/src/lib/core.module.ts @@ -38,6 +38,7 @@ import { SafeHtmlPipe } from './pipes/safe-html.pipe'; import { QUEUE_MANAGER } from './tokens/queue.token'; import { DefaultQueueManager } from './utils/queue'; import { IncludeLocalizationResourcesProvider } from './providers/include-localization-resources.provider'; +import { SORT_COMPARE_FUNC, compareFuncFactory } from './tokens/compare-func.token'; /** * BaseCoreModule is the module that holds @@ -176,6 +177,10 @@ export class CoreModule { useValue: localizationContributor(options.localizations), deps: [LocalizationService], }, + { + provide: SORT_COMPARE_FUNC, + useFactory: compareFuncFactory + }, { provide: QUEUE_MANAGER, useClass: DefaultQueueManager, diff --git a/npm/ng-packs/packages/core/src/lib/services/routes.service.ts b/npm/ng-packs/packages/core/src/lib/services/routes.service.ts index 329d2a370c..c3a1ffe07f 100644 --- a/npm/ng-packs/packages/core/src/lib/services/routes.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/routes.service.ts @@ -12,6 +12,7 @@ import { } from '../utils/tree-utils'; import { ConfigStateService } from './config-state.service'; import { PermissionService } from './permission.service'; +import { SORT_COMPARE_FUNC } from '../tokens/compare-func.token'; // eslint-disable-next-line @typescript-eslint/ban-types export abstract class AbstractTreeService { @@ -158,14 +159,12 @@ export abstract class AbstractNavTreeService { private subscription: Subscription; private permissionService: PermissionService; + private compareFunc; readonly id = 'name'; readonly parentId = 'parentName'; readonly hide = (item: T) => item.invisible || !this.isGranted(item); readonly sort = (a: T, b: T) => { - if (!Number.isInteger(a.order)) return 1; - if (!Number.isInteger(b.order)) return -1; - - return (a.order as number) - (b.order as number); + return this.compareFunc(a,b) }; constructor(protected injector: Injector) { @@ -176,6 +175,7 @@ export abstract class AbstractNavTreeService .subscribe(() => this.refresh()); this.permissionService = injector.get(PermissionService); this.othersGroup = injector.get(OTHERS_GROUP); + this.compareFunc = injector.get(SORT_COMPARE_FUNC); } protected isGranted({ requiredPolicy }: T): boolean { diff --git a/npm/ng-packs/packages/core/src/lib/tests/capsLock.directive.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/capsLock.directive.spec.ts new file mode 100644 index 0000000000..3182dfa2dd --- /dev/null +++ b/npm/ng-packs/packages/core/src/lib/tests/capsLock.directive.spec.ts @@ -0,0 +1,57 @@ +import { Component, DebugElement } from '@angular/core' +import { ComponentFixture, TestBed } from '@angular/core/testing' +import { TrackCapsLockDirective } from '../directives'; +import { By } from '@angular/platform-browser'; + +@Component({ + standalone:true, + template: ` + + `, + imports:[TrackCapsLockDirective] +}) +class TestComponent { + capsLock:boolean = false +} + +describe('TrackCapsLockDirective',()=>{ + let fixture: ComponentFixture;; + let des : DebugElement[]; + + beforeEach(()=>{ + fixture = TestBed.configureTestingModule({ + imports: [ TestComponent ] + }).createComponent(TestComponent); + + fixture.detectChanges(); + + des = fixture.debugElement.queryAll(By.directive(TrackCapsLockDirective)); + }); + + test.each(['keydown','keyup'])('is %p works when press capslock and is emit status', (eventName) => { + const event = new KeyboardEvent(eventName, { + key: 'CapsLock', + modifierCapsLock: true + }); + window.dispatchEvent(event); + fixture.detectChanges(); + expect(fixture.componentInstance.capsLock).toBe(true) + }); + + test.each(['keydown','keyup'])('is %p detect the change capslock is emit status', (eventName) => { + const trueEvent = new KeyboardEvent(eventName, { + key: 'CapsLock', + modifierCapsLock: true + }); + window.dispatchEvent(trueEvent); + fixture.detectChanges(); + expect(fixture.componentInstance.capsLock).toBe(true) + const falseEvent = new KeyboardEvent(eventName, { + key: 'CapsLock', + modifierCapsLock: false + }); + window.dispatchEvent(falseEvent); + fixture.detectChanges(); + expect(fixture.componentInstance.capsLock).toBe(false) + }); + }); \ No newline at end of file diff --git a/npm/ng-packs/packages/core/src/lib/tests/show-password-directive.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/show-password-directive.spec.ts new file mode 100644 index 0000000000..8babb472c4 --- /dev/null +++ b/npm/ng-packs/packages/core/src/lib/tests/show-password-directive.spec.ts @@ -0,0 +1,55 @@ +import { Component, DebugElement } from '@angular/core' +import { ComponentFixture, TestBed } from '@angular/core/testing' +import { ShowPasswordDirective } from '../directives'; +import { By } from '@angular/platform-browser'; + +@Component({ + standalone:true, + template: ` + + + + `, + imports:[ShowPasswordDirective] +}) +class TestComponent { + showPassword:boolean = false +} + +describe('ShowPasswordDirective',()=>{ + let fixture: ComponentFixture;; + let des : DebugElement[]; + let desAll : DebugElement[]; + let bareInput; + + beforeEach(()=>{ + fixture = TestBed.configureTestingModule({ + imports: [ TestComponent ] + }).createComponent(TestComponent) + + fixture.detectChanges(); + + des = fixture.debugElement.queryAll(By.directive(ShowPasswordDirective)); + + desAll = fixture.debugElement.queryAll(By.all()); + + bareInput = fixture.debugElement.query(By.css('input:not([abpShowPassword])')); + }) + + it('should have three input has ShowPasswordDirective elements', () => { + expect(des.length).toBe(3); + }); + + test.each([[0,'text'],[1,'password'],[2,'text'],[3,'password']])('%p. input type must be %p)', (index,inpType) => { + const inputType = desAll[index].nativeElement.type; + expect(inputType).toBe(inpType); + }); + + it('should have three input has ShowPasswordDirective elements', () => { + let input = des[2].nativeElement + expect(input.type).toBe('password') + fixture.componentInstance.showPassword = true + fixture.detectChanges() + expect(input.type).toBe('text') + }); + }); \ No newline at end of file diff --git a/npm/ng-packs/packages/core/src/lib/tokens/compare-func.token.ts b/npm/ng-packs/packages/core/src/lib/tokens/compare-func.token.ts new file mode 100644 index 0000000000..bf66ec2b54 --- /dev/null +++ b/npm/ng-packs/packages/core/src/lib/tokens/compare-func.token.ts @@ -0,0 +1,27 @@ +import { InjectionToken, inject } from '@angular/core'; +import { LocalizationService } from '../services'; + +export const SORT_COMPARE_FUNC = new InjectionToken< 0 | 1 | -1 >('SORT_COMPARE_FUNC'); + +export function compareFuncFactory() { + const localizationService = inject(LocalizationService) + const fn = (a,b) => { + const aName = localizationService.instant(a.name); + const bName = localizationService.instant(b.name); + const aNumber = a.order; + const bNumber = b.order; + + if (!Number.isInteger(aNumber)) return 1; + if (!Number.isInteger(bNumber)) return -1; + + if (aNumber > bNumber) return 1 + if (aNumber < bNumber) return -1 + + if ( aName > bName ) return 1; + if ( aName < bName ) return -1; + + return 0 + } + + return fn +} \ No newline at end of file diff --git a/npm/ng-packs/packages/feature-management/src/lib/providers/feature-management-settings.provider.ts b/npm/ng-packs/packages/feature-management/src/lib/providers/feature-management-settings.provider.ts index 2d7664bb46..64bbfb9932 100644 --- a/npm/ng-packs/packages/feature-management/src/lib/providers/feature-management-settings.provider.ts +++ b/npm/ng-packs/packages/feature-management/src/lib/providers/feature-management-settings.provider.ts @@ -17,7 +17,7 @@ export function configureSettingTabs(settingtabs: SettingTabsService) { settingtabs.add([ { name: eFeatureManagementTabNames.FeatureManagement, - order: 104, + order: 100, requiredPolicy: 'FeatureManagement.ManageHostFeatures', component: FeatureManagementTabComponent, }, diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html index 5fc312a92d..2e1dc7608f 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html @@ -7,7 +7,7 @@ -
+
[]> = of([]); diff --git a/npm/ng-packs/packages/theme-shared/src/lib/models/nav-item.ts b/npm/ng-packs/packages/theme-shared/src/lib/models/nav-item.ts index 706eb1cb6c..c673bc74e2 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/models/nav-item.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/models/nav-item.ts @@ -1,8 +1,17 @@ import { Injector, Type } from '@angular/core'; import { Observable, of } from 'rxjs'; +export interface Badge { + count?: number | Observable; + color?: string; + icon?: string; +} + export class NavItem { id?: string | number; + name?: string; + description?: string; + badge?: Badge; component?: Type; html?: string; action?: () => void;