From d238bd2cbb978e636a1bf87d310b82e966fbe293 Mon Sep 17 00:00:00 2001 From: Ahmad Almunajjed Date: Sat, 13 Apr 2024 17:32:14 +0800 Subject: [PATCH 01/14] add skipiInitAuthService to ABP.Root in ng core package --- npm/ng-packs/packages/core/src/lib/models/common.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/npm/ng-packs/packages/core/src/lib/models/common.ts b/npm/ng-packs/packages/core/src/lib/models/common.ts index 6d30a6ec74..ffc7d21dcf 100644 --- a/npm/ng-packs/packages/core/src/lib/models/common.ts +++ b/npm/ng-packs/packages/core/src/lib/models/common.ts @@ -9,6 +9,7 @@ export namespace ABP { environment: Partial; registerLocaleFn: (locale: string) => Promise; skipGetAppConfiguration?: boolean; + skipiInitAuthService?: boolean; sendNullsAsQueryParam?: boolean; tenantKey?: string; localizations?: Localization[]; From a8fb824da8a1bd9437c8181004741c7b58e3fac0 Mon Sep 17 00:00:00 2001 From: Ahmad Almunajjed Date: Sat, 13 Apr 2024 17:37:25 +0800 Subject: [PATCH 02/14] make calling authService.init() optional based on option --- npm/ng-packs/packages/core/src/lib/utils/initial-utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/core/src/lib/utils/initial-utils.ts b/npm/ng-packs/packages/core/src/lib/utils/initial-utils.ts index 782af0899d..24dde2e3a4 100644 --- a/npm/ng-packs/packages/core/src/lib/utils/initial-utils.ts +++ b/npm/ng-packs/packages/core/src/lib/utils/initial-utils.ts @@ -29,7 +29,7 @@ export function getInitialData(injector: Injector) { const checkAuthenticationState = injector.get(CHECK_AUTHENTICATION_STATE_FN_KEY, noop, { optional: true, }); - if (authService) { + if (!options.skipiInitAuthService && authService) { await authService.init(); } if (options.skipGetAppConfiguration) return; From d4f35648f9f535014dfbd3d07aec4e1456d425cb Mon Sep 17 00:00:00 2001 From: Ahmad Almunajjed Date: Sat, 13 Apr 2024 10:09:58 +0000 Subject: [PATCH 03/14] fix typo --- npm/ng-packs/packages/core/src/lib/models/common.ts | 2 +- npm/ng-packs/packages/core/src/lib/utils/initial-utils.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/models/common.ts b/npm/ng-packs/packages/core/src/lib/models/common.ts index ffc7d21dcf..714f2422c2 100644 --- a/npm/ng-packs/packages/core/src/lib/models/common.ts +++ b/npm/ng-packs/packages/core/src/lib/models/common.ts @@ -9,7 +9,7 @@ export namespace ABP { environment: Partial; registerLocaleFn: (locale: string) => Promise; skipGetAppConfiguration?: boolean; - skipiInitAuthService?: boolean; + skipInitAuthService?: boolean; sendNullsAsQueryParam?: boolean; tenantKey?: string; localizations?: Localization[]; diff --git a/npm/ng-packs/packages/core/src/lib/utils/initial-utils.ts b/npm/ng-packs/packages/core/src/lib/utils/initial-utils.ts index 24dde2e3a4..4173bd96c6 100644 --- a/npm/ng-packs/packages/core/src/lib/utils/initial-utils.ts +++ b/npm/ng-packs/packages/core/src/lib/utils/initial-utils.ts @@ -29,7 +29,7 @@ export function getInitialData(injector: Injector) { const checkAuthenticationState = injector.get(CHECK_AUTHENTICATION_STATE_FN_KEY, noop, { optional: true, }); - if (!options.skipiInitAuthService && authService) { + if (!options.skipInitAuthService && authService) { await authService.init(); } if (options.skipGetAppConfiguration) return; From d52e3fe49a86a05723bd551067386cc5489c8e80 Mon Sep 17 00:00:00 2001 From: Volosoft Agent <43883821+voloagent@users.noreply.github.com> Date: Tue, 16 Apr 2024 11:37:40 +0300 Subject: [PATCH 04/14] Update latest-versions.json to version 8.1.1 --- latest-versions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/latest-versions.json b/latest-versions.json index 25de5e6076..67108ad57a 100644 --- a/latest-versions.json +++ b/latest-versions.json @@ -1,6 +1,6 @@ [ { - "version": "8.1.0", + "version": "8.1.1", "releaseDate": "", "type": "stable", "message": "" From 2f80b3a980647672300f2b42ec5d1b7dea26a0ee Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 17 Apr 2024 20:55:27 +0800 Subject: [PATCH 05/14] Add AbpAuthenticationSessionStateViewComponent to logout from other tabs for MVC UI --- .../AbpAspNetCoreMvcUiThemeSharedModule.cs | 8 +++ ...AuthenticationSessionStateViewComponent.cs | 11 ++++ .../Default.cshtml | 61 +++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationSessionState/AbpAuthenticationSessionStateViewComponent.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationSessionState/Default.cshtml diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs index 109746e34f..c9069bd5e3 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs @@ -3,8 +3,11 @@ using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Packages; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Bundling; +using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Shared.Components.AbpAuthenticationSessionState; +using Volo.Abp.AspNetCore.Mvc.UI.Theming; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; using Volo.Abp.Modularity; +using Volo.Abp.Ui.LayoutHooks; using Volo.Abp.VirtualFileSystem; namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; @@ -30,6 +33,11 @@ public class AbpAspNetCoreMvcUiThemeSharedModule : AbpModule { options.FileSets.AddEmbedded("Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared"); }); + + Configure(options => + { + options.Add(LayoutHooks.Body.Last, typeof(AbpAuthenticationSessionStateViewComponent)); + }); Configure(options => { diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationSessionState/AbpAuthenticationSessionStateViewComponent.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationSessionState/AbpAuthenticationSessionStateViewComponent.cs new file mode 100644 index 0000000000..ceb9a32b91 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationSessionState/AbpAuthenticationSessionStateViewComponent.cs @@ -0,0 +1,11 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Shared.Components.AbpAuthenticationSessionState; + +public class AbpAuthenticationSessionStateViewComponent : AbpViewComponent +{ +public virtual IViewComponentResult Invoke() +{ + return View("~/Pages/Shared/Components/AbpAuthenticationSessionState/Default.cshtml"); +} +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationSessionState/Default.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationSessionState/Default.cshtml new file mode 100644 index 0000000000..8c07e6fccf --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationSessionState/Default.cshtml @@ -0,0 +1,61 @@ + \ No newline at end of file From e90ac0acd5cb08c39b644ce4bfcc7fae9d14a242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20=C3=87=C4=B1rak?= Date: Wed, 17 Apr 2024 17:13:32 +0300 Subject: [PATCH 06/14] adding OTHERS_GROUP and SORT_COMPARE_FUNC injection tokens to CoreTestingModule to prevent injection errors --- .../core/testing/src/lib/core-testing.module.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/core/testing/src/lib/core-testing.module.ts b/npm/ng-packs/packages/core/testing/src/lib/core-testing.module.ts index 8aab44d44b..8f077fa628 100644 --- a/npm/ng-packs/packages/core/testing/src/lib/core-testing.module.ts +++ b/npm/ng-packs/packages/core/testing/src/lib/core-testing.module.ts @@ -8,6 +8,9 @@ import { PermissionService, RestService, INCUDE_LOCALIZATION_RESOURCES_TOKEN, + OTHERS_GROUP, + compareFuncFactory, + SORT_COMPARE_FUNC, } from '@abp/ng.core'; import { APP_BASE_HREF } from '@angular/common'; import { ModuleWithProviders, NgModule } from '@angular/core'; @@ -16,6 +19,7 @@ import { provideRoutes } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { MockPermissionService } from './services/mock-permission.service'; import { MockRestService } from './services/mock-rest.service'; +import { LocalizationPipe } from './pipes'; /** * CoreTestingModule is the module that will be used in tests @@ -23,7 +27,7 @@ import { MockRestService } from './services/mock-rest.service'; */ @NgModule({ exports: [RouterTestingModule, BaseCoreModule], - imports: [NoopAnimationsModule, RouterTestingModule, BaseCoreModule], + imports: [NoopAnimationsModule, RouterTestingModule, BaseCoreModule, LocalizationPipe], }) export class CoreTestingModule { static withConfig( @@ -65,6 +69,14 @@ export class CoreTestingModule { provide: INCUDE_LOCALIZATION_RESOURCES_TOKEN, useValue: false, }, + { + provide: OTHERS_GROUP, + useValue: 'AbpUi::OthersGroup', + }, + { + provide: SORT_COMPARE_FUNC, + useFactory: compareFuncFactory, + }, provideRoutes(routes), ], }; From 4c32eb94ef42aeeda775095b4f54664f943d22b4 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 18 Apr 2024 12:36:39 +0800 Subject: [PATCH 07/14] Update Rebus package to fix Host start failed --- Directory.Packages.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 9624cc0740..9c4dc50e34 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -127,8 +127,8 @@ - - + + From 17934b9036c18245f0f4d083e6ceec550163713d Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 18 Apr 2024 14:13:29 +0800 Subject: [PATCH 08/14] Rename AbpAuthenticationSessionStateViewComponent to AbpAuthenticationStateViewComponent --- .../AbpAspNetCoreMvcUiThemeSharedModule.cs | 4 +- ...AuthenticationSessionStateViewComponent.cs | 11 ---- .../Default.cshtml | 61 ------------------- .../AbpAuthenticationStateViewComponent.cs | 11 ++++ .../AbpAuthenticationState/Default.cshtml | 48 +++++++++++++++ 5 files changed, 61 insertions(+), 74 deletions(-) delete mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationSessionState/AbpAuthenticationSessionStateViewComponent.cs delete mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationSessionState/Default.cshtml create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationState/AbpAuthenticationStateViewComponent.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationState/Default.cshtml diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs index c9069bd5e3..5f4ef0d192 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs @@ -3,7 +3,7 @@ using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Packages; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Bundling; -using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Shared.Components.AbpAuthenticationSessionState; +using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Shared.Components.AbpAuthenticationState; using Volo.Abp.AspNetCore.Mvc.UI.Theming; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; using Volo.Abp.Modularity; @@ -36,7 +36,7 @@ public class AbpAspNetCoreMvcUiThemeSharedModule : AbpModule Configure(options => { - options.Add(LayoutHooks.Body.Last, typeof(AbpAuthenticationSessionStateViewComponent)); + options.Add(LayoutHooks.Body.Last, typeof(AbpAuthenticationStateViewComponent)); }); Configure(options => diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationSessionState/AbpAuthenticationSessionStateViewComponent.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationSessionState/AbpAuthenticationSessionStateViewComponent.cs deleted file mode 100644 index ceb9a32b91..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationSessionState/AbpAuthenticationSessionStateViewComponent.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Microsoft.AspNetCore.Mvc; - -namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Shared.Components.AbpAuthenticationSessionState; - -public class AbpAuthenticationSessionStateViewComponent : AbpViewComponent -{ -public virtual IViewComponentResult Invoke() -{ - return View("~/Pages/Shared/Components/AbpAuthenticationSessionState/Default.cshtml"); -} -} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationSessionState/Default.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationSessionState/Default.cshtml deleted file mode 100644 index 8c07e6fccf..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationSessionState/Default.cshtml +++ /dev/null @@ -1,61 +0,0 @@ - \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationState/AbpAuthenticationStateViewComponent.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationState/AbpAuthenticationStateViewComponent.cs new file mode 100644 index 0000000000..f48c63b6d5 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationState/AbpAuthenticationStateViewComponent.cs @@ -0,0 +1,11 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Shared.Components.AbpAuthenticationState; + +public class AbpAuthenticationStateViewComponent : AbpViewComponent +{ +public virtual IViewComponentResult Invoke() +{ + return View("~/Pages/Shared/Components/AbpAuthenticationState/Default.cshtml"); +} +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationState/Default.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationState/Default.cshtml new file mode 100644 index 0000000000..f9112b1de7 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationState/Default.cshtml @@ -0,0 +1,48 @@ + \ No newline at end of file From 4ecd310f0d1e23f332a41da5945550433cc9b1f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20=C3=87=C4=B1rak?= Date: Thu, 18 Apr 2024 09:45:49 +0300 Subject: [PATCH 09/14] chore(core): Add others group and sort compare func injection tokens to core testing module to prevent injection errors --- .../core/testing/src/lib/core-testing.module.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/npm/ng-packs/packages/core/testing/src/lib/core-testing.module.ts b/npm/ng-packs/packages/core/testing/src/lib/core-testing.module.ts index 8aab44d44b..f5b99118f7 100644 --- a/npm/ng-packs/packages/core/testing/src/lib/core-testing.module.ts +++ b/npm/ng-packs/packages/core/testing/src/lib/core-testing.module.ts @@ -8,6 +8,9 @@ import { PermissionService, RestService, INCUDE_LOCALIZATION_RESOURCES_TOKEN, + OTHERS_GROUP, + compareFuncFactory, + SORT_COMPARE_FUNC, } from '@abp/ng.core'; import { APP_BASE_HREF } from '@angular/common'; import { ModuleWithProviders, NgModule } from '@angular/core'; @@ -65,6 +68,14 @@ export class CoreTestingModule { provide: INCUDE_LOCALIZATION_RESOURCES_TOKEN, useValue: false, }, + { + provide: OTHERS_GROUP, + useValue: 'AbpUi::OthersGroup', + }, + { + provide: SORT_COMPARE_FUNC, + useFactory: compareFuncFactory, + }, provideRoutes(routes), ], }; From 684ab909502a3a3126c0389318cba1357c672bf1 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 18 Apr 2024 15:36:43 +0800 Subject: [PATCH 10/14] Add authentication-state-listener.js --- .../AbpAspNetCoreMvcUiThemeSharedModule.cs | 8 ---- .../SharedThemeGlobalScriptContributor.cs | 3 +- .../AbpAuthenticationStateViewComponent.cs | 11 ----- .../AbpAuthenticationState/Default.cshtml | 48 ------------------- .../authentication-state-listener.js | 30 ++++++++++++ 5 files changed, 32 insertions(+), 68 deletions(-) delete mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationState/AbpAuthenticationStateViewComponent.cs delete mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationState/Default.cshtml create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/authentication-state/authentication-state-listener.js diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs index 5f4ef0d192..b62d3f27ba 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs @@ -3,11 +3,8 @@ using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Packages; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Bundling; -using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Shared.Components.AbpAuthenticationState; -using Volo.Abp.AspNetCore.Mvc.UI.Theming; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; using Volo.Abp.Modularity; -using Volo.Abp.Ui.LayoutHooks; using Volo.Abp.VirtualFileSystem; namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; @@ -34,11 +31,6 @@ public class AbpAspNetCoreMvcUiThemeSharedModule : AbpModule options.FileSets.AddEmbedded("Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared"); }); - Configure(options => - { - options.Add(LayoutHooks.Body.Last, typeof(AbpAuthenticationStateViewComponent)); - }); - Configure(options => { options diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalScriptContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalScriptContributor.cs index 27f3760000..5d8c15ba40 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalScriptContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalScriptContributor.cs @@ -49,7 +49,8 @@ public class SharedThemeGlobalScriptContributor : BundleContributor "/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js", "/libs/abp/aspnetcore-mvc-ui-theme-shared/sweetalert2/abp-sweetalert2.js", "/libs/abp/aspnetcore-mvc-ui-theme-shared/toastr/abp-toastr.js", - "/libs/abp/aspnetcore-mvc-ui-theme-shared/date-range-picker/date-range-picker-extensions.js" + "/libs/abp/aspnetcore-mvc-ui-theme-shared/date-range-picker/date-range-picker-extensions.js", + "/libs/abp/aspnetcore-mvc-ui-theme-shared/authentication-state/authentication-state-listener.js" }); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationState/AbpAuthenticationStateViewComponent.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationState/AbpAuthenticationStateViewComponent.cs deleted file mode 100644 index f48c63b6d5..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationState/AbpAuthenticationStateViewComponent.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Microsoft.AspNetCore.Mvc; - -namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Shared.Components.AbpAuthenticationState; - -public class AbpAuthenticationStateViewComponent : AbpViewComponent -{ -public virtual IViewComponentResult Invoke() -{ - return View("~/Pages/Shared/Components/AbpAuthenticationState/Default.cshtml"); -} -} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationState/Default.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationState/Default.cshtml deleted file mode 100644 index f9112b1de7..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpAuthenticationState/Default.cshtml +++ /dev/null @@ -1,48 +0,0 @@ - \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/authentication-state/authentication-state-listener.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/authentication-state/authentication-state-listener.js new file mode 100644 index 0000000000..1b6ec69602 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/authentication-state/authentication-state-listener.js @@ -0,0 +1,30 @@ +(function () { + + const stateKey = 'authentication-state-id'; + + window.addEventListener('load', function () { + if (!abp || !abp.currentUser) { + return; + } + + if (!abp.currentUser.isAuthenticated){ + localStorage.removeItem(stateKey); + }else{ + localStorage.setItem(stateKey, abp.currentUser.id); + } + + window.addEventListener('storage', function (event) { + + if (event.key !== stateKey || event.oldValue === event.newValue) { + return; + } + + if(event.oldValue || !event.newValue) { + window.location.reload(); + }else{ + location.assign('/') + } + }); + }); + +}()); \ No newline at end of file From f9eb84cbc01cbacc1b0c9c0d252395225c49b3c1 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 18 Apr 2024 15:45:53 +0800 Subject: [PATCH 11/14] Update authentication-state-listener.js --- .../authentication-state-listener.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/authentication-state/authentication-state-listener.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/authentication-state/authentication-state-listener.js index 1b6ec69602..848760f854 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/authentication-state/authentication-state-listener.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/authentication-state/authentication-state-listener.js @@ -1,30 +1,30 @@ (function () { - + const stateKey = 'authentication-state-id'; window.addEventListener('load', function () { if (!abp || !abp.currentUser) { return; } - - if (!abp.currentUser.isAuthenticated){ + + if (!abp.currentUser.isAuthenticated) { localStorage.removeItem(stateKey); - }else{ + } else { localStorage.setItem(stateKey, abp.currentUser.id); } window.addEventListener('storage', function (event) { - + if (event.key !== stateKey || event.oldValue === event.newValue) { return; } - - if(event.oldValue || !event.newValue) { + + if (event.oldValue || !event.newValue) { window.location.reload(); - }else{ + } else { location.assign('/') } }); }); - + }()); \ No newline at end of file From 81a7f323c0f155522cabbe3f003b631b1fec5237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20=C3=87=C4=B1rak?= Date: Thu, 18 Apr 2024 16:43:20 +0300 Subject: [PATCH 12/14] enhancement(core): Add SortableItem type, add sorting by id to compareFuncFactory, sort by compareFuncFactoy in AbstractMenuService --- .../packages/core/src/lib/models/index.ts | 1 + .../packages/core/src/lib/models/sort.ts | 5 +++ .../core/src/lib/tokens/compare-func.token.ts | 38 +++++++++++-------- .../src/lib/services/abstract-menu.service.ts | 14 +++---- 4 files changed, 35 insertions(+), 23 deletions(-) create mode 100644 npm/ng-packs/packages/core/src/lib/models/sort.ts diff --git a/npm/ng-packs/packages/core/src/lib/models/index.ts b/npm/ng-packs/packages/core/src/lib/models/index.ts index c343ee2440..0156b77bda 100644 --- a/npm/ng-packs/packages/core/src/lib/models/index.ts +++ b/npm/ng-packs/packages/core/src/lib/models/index.ts @@ -8,3 +8,4 @@ export * from './session'; export * from './utility'; export * from './auth'; export * from './auth-events'; +export * from './sort'; diff --git a/npm/ng-packs/packages/core/src/lib/models/sort.ts b/npm/ng-packs/packages/core/src/lib/models/sort.ts new file mode 100644 index 0000000000..eb51d18d22 --- /dev/null +++ b/npm/ng-packs/packages/core/src/lib/models/sort.ts @@ -0,0 +1,5 @@ +export interface SortableItem { + id?: string | number; + name?: string; + order?: number; +} 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 index bf66ec2b54..2c5185ce23 100644 --- 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 @@ -1,27 +1,33 @@ import { InjectionToken, inject } from '@angular/core'; +import { SortableItem } from '../models'; import { LocalizationService } from '../services'; -export const SORT_COMPARE_FUNC = new InjectionToken< 0 | 1 | -1 >('SORT_COMPARE_FUNC'); +export const SORT_COMPARE_FUNC = new InjectionToken<(a: SortableItem, b: SortableItem) => number>( + 'SORT_COMPARE_FUNC', +); export function compareFuncFactory() { - const localizationService = inject(LocalizationService) - const fn = (a,b) => { + const localizationService = inject(LocalizationService); + const fn = (a: SortableItem, b: SortableItem) => { 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 + + if (aNumber > bNumber) return 1; + if (aNumber < bNumber) return -1; + + if (aName > bName) return 1; + if (aName < bName) return -1; + + if (a.id > b.id) return 1; + if (a.id < b.id) return -1; + + return 0; + }; + + return fn; +} diff --git a/npm/ng-packs/packages/theme-shared/src/lib/services/abstract-menu.service.ts b/npm/ng-packs/packages/theme-shared/src/lib/services/abstract-menu.service.ts index e1048f907e..4c3137b332 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/services/abstract-menu.service.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/services/abstract-menu.service.ts @@ -1,10 +1,13 @@ import { BehaviorSubject, Observable } from 'rxjs'; import { NavItem } from '../models/nav-item'; -import { Type } from '@angular/core'; +import { inject, Type } from '@angular/core'; +import { SORT_COMPARE_FUNC } from '@abp/ng.core'; export abstract class AbstractMenuService { protected abstract baseClass: Type; + protected readonly sortFn = inject(SORT_COMPARE_FUNC); + protected _items$ = new BehaviorSubject([]); get items(): T[] { @@ -52,10 +55,7 @@ export abstract class AbstractMenuService { this._items$.next(items); } - private sortItems(a: T, b: T) { - if (!a.order) return 1; - if (!b.order) return -1; - - return a.order - b.order; - } + sortItems = (a: T, b: T) => { + return this.sortFn(a, b); + }; } From 368df4216be5486e3b958a529349e51bf8b8ed33 Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 19 Apr 2024 10:35:33 +0800 Subject: [PATCH 13/14] Make `BackgroundEmailSendingJobArgs ` support `IMultiTenant` --- .../Abp/Emailing/BackgroundEmailSendingJobArgs.cs | 5 ++++- .../Volo/Abp/Emailing/EmailSenderBase.cs | 11 ++++++++++- .../Volo/Abp/Emailing/NullEmailSender.cs | 5 +++-- .../Volo/Abp/Emailing/Smtp/SmtpEmailSender.cs | 4 +++- .../Volo/Abp/MailKit/MailKitSmtpEmailSender.cs | 7 +++++-- .../Volo/Abp/MailKit/MailKitSmtpEmailSender_Tests.cs | 4 +++- 6 files changed, 28 insertions(+), 8 deletions(-) diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/BackgroundEmailSendingJobArgs.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/BackgroundEmailSendingJobArgs.cs index 86a34b4210..0b30a9bfd1 100644 --- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/BackgroundEmailSendingJobArgs.cs +++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/BackgroundEmailSendingJobArgs.cs @@ -1,12 +1,15 @@ using System; using System.Collections.Generic; using Volo.Abp.Data; +using Volo.Abp.MultiTenancy; namespace Volo.Abp.Emailing; [Serializable] -public class BackgroundEmailSendingJobArgs +public class BackgroundEmailSendingJobArgs : IMultiTenant { + public Guid? TenantId { get; set; } + public string? From { get; set; } public string To { get; set; } = default!; diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailSenderBase.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailSenderBase.cs index 55d4b50a58..164674f7c3 100644 --- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailSenderBase.cs +++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailSenderBase.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Volo.Abp.BackgroundJobs; +using Volo.Abp.MultiTenancy; namespace Volo.Abp.Emailing; @@ -17,6 +18,8 @@ public abstract class EmailSenderBase : IEmailSender { public ILogger Logger { get; set; } + protected ICurrentTenant CurrentTenant { get; } + protected IEmailSenderConfiguration Configuration { get; } protected IBackgroundJobManager BackgroundJobManager { get; } @@ -24,10 +27,14 @@ public abstract class EmailSenderBase : IEmailSender /// /// Constructor. /// - protected EmailSenderBase(IEmailSenderConfiguration configuration, IBackgroundJobManager backgroundJobManager) + protected EmailSenderBase( + ICurrentTenant currentTenant, + IEmailSenderConfiguration configuration, + IBackgroundJobManager backgroundJobManager) { Logger = NullLogger.Instance; + CurrentTenant = currentTenant; Configuration = configuration; BackgroundJobManager = backgroundJobManager; } @@ -93,6 +100,7 @@ public abstract class EmailSenderBase : IEmailSender await BackgroundJobManager.EnqueueAsync( new BackgroundEmailSendingJobArgs { + TenantId = CurrentTenant.Id, To = to, Subject = subject, Body = body, @@ -113,6 +121,7 @@ public abstract class EmailSenderBase : IEmailSender await BackgroundJobManager.EnqueueAsync( new BackgroundEmailSendingJobArgs { + TenantId = CurrentTenant.Id, From = from, To = to, Subject = subject, diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/NullEmailSender.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/NullEmailSender.cs index 48fa8004ef..f73783ebeb 100644 --- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/NullEmailSender.cs +++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/NullEmailSender.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Volo.Abp.BackgroundJobs; +using Volo.Abp.MultiTenancy; namespace Volo.Abp.Emailing; @@ -15,8 +16,8 @@ public class NullEmailSender : EmailSenderBase /// /// Creates a new object. /// - public NullEmailSender(IEmailSenderConfiguration configuration, IBackgroundJobManager backgroundJobManager) - : base(configuration, backgroundJobManager) + public NullEmailSender(ICurrentTenant currentTenant, IEmailSenderConfiguration configuration, IBackgroundJobManager backgroundJobManager) + : base(currentTenant, configuration, backgroundJobManager) { } diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Smtp/SmtpEmailSender.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Smtp/SmtpEmailSender.cs index 62550c41f7..babb9f9d9a 100644 --- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Smtp/SmtpEmailSender.cs +++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Smtp/SmtpEmailSender.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Volo.Abp.BackgroundJobs; using Volo.Abp.DependencyInjection; +using Volo.Abp.MultiTenancy; namespace Volo.Abp.Emailing.Smtp; @@ -19,9 +20,10 @@ public class SmtpEmailSender : EmailSenderBase, ISmtpEmailSender, ITransientDepe /// Creates a new . /// public SmtpEmailSender( + ICurrentTenant currentTenant, ISmtpEmailSenderConfiguration smtpConfiguration, IBackgroundJobManager backgroundJobManager) - : base(smtpConfiguration, backgroundJobManager) + : base(currentTenant, smtpConfiguration, backgroundJobManager) { SmtpConfiguration = smtpConfiguration; } diff --git a/framework/src/Volo.Abp.MailKit/Volo/Abp/MailKit/MailKitSmtpEmailSender.cs b/framework/src/Volo.Abp.MailKit/Volo/Abp/MailKit/MailKitSmtpEmailSender.cs index 96e436760e..c4fbd1be5e 100644 --- a/framework/src/Volo.Abp.MailKit/Volo/Abp/MailKit/MailKitSmtpEmailSender.cs +++ b/framework/src/Volo.Abp.MailKit/Volo/Abp/MailKit/MailKitSmtpEmailSender.cs @@ -9,6 +9,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using MimeKit; using MimeKit.Utils; +using Volo.Abp.MultiTenancy; using SmtpClient = MailKit.Net.Smtp.SmtpClient; namespace Volo.Abp.MailKit; @@ -20,10 +21,12 @@ public class MailKitSmtpEmailSender : EmailSenderBase, IMailKitSmtpEmailSender protected ISmtpEmailSenderConfiguration SmtpConfiguration { get; } - public MailKitSmtpEmailSender(ISmtpEmailSenderConfiguration smtpConfiguration, + public MailKitSmtpEmailSender( + ICurrentTenant currentTenant, + ISmtpEmailSenderConfiguration smtpConfiguration, IBackgroundJobManager backgroundJobManager, IOptions abpMailKitConfiguration) - : base(smtpConfiguration, backgroundJobManager) + : base(currentTenant, smtpConfiguration, backgroundJobManager) { AbpMailKitOptions = abpMailKitConfiguration.Value; SmtpConfiguration = smtpConfiguration; diff --git a/framework/test/Volo.Abp.MailKit.Tests/Volo/Abp/MailKit/MailKitSmtpEmailSender_Tests.cs b/framework/test/Volo.Abp.MailKit.Tests/Volo/Abp/MailKit/MailKitSmtpEmailSender_Tests.cs index 18c84b2e0b..adc2edf31b 100644 --- a/framework/test/Volo.Abp.MailKit.Tests/Volo/Abp/MailKit/MailKitSmtpEmailSender_Tests.cs +++ b/framework/test/Volo.Abp.MailKit.Tests/Volo/Abp/MailKit/MailKitSmtpEmailSender_Tests.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using NSubstitute; using Volo.Abp.BackgroundJobs; using Volo.Abp.Emailing.Smtp; +using Volo.Abp.MultiTenancy; using Volo.Abp.Testing; using Xunit; @@ -35,6 +36,7 @@ public class MailKitSmtpEmailSender_Tests : AbpIntegratedTest(); var mailConfig = Substitute.For(); var bgJob = Substitute.For(); @@ -44,7 +46,7 @@ public class MailKitSmtpEmailSender_Tests : AbpIntegratedTest Date: Fri, 19 Apr 2024 14:49:43 +0800 Subject: [PATCH 14/14] Get dynamic claims in `AbpAuthenticationHubFilter`. --- .../AbpAuthenticationHubFilter.cs | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/Authentication/AbpAuthenticationHubFilter.cs b/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/Authentication/AbpAuthenticationHubFilter.cs index ab79521159..baac1b538f 100644 --- a/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/Authentication/AbpAuthenticationHubFilter.cs +++ b/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/Authentication/AbpAuthenticationHubFilter.cs @@ -1,7 +1,9 @@ using System; +using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using Volo.Abp.Security.Claims; namespace Volo.Abp.AspNetCore.SignalR.Authentication; @@ -11,7 +13,7 @@ public class AbpAuthenticationHubFilter : IHubFilter public virtual async ValueTask InvokeMethodAsync(HubInvocationContext invocationContext, Func> next) { var currentPrincipalAccessor = invocationContext.ServiceProvider.GetRequiredService(); - using (currentPrincipalAccessor.Change(invocationContext.Context.User!)) + using (currentPrincipalAccessor.Change((await GetDynamicClaimsPrincipalAsync(invocationContext.Context.User, invocationContext.ServiceProvider))!)) { return await next(invocationContext); } @@ -20,7 +22,7 @@ public class AbpAuthenticationHubFilter : IHubFilter public virtual async Task OnConnectedAsync(HubLifetimeContext context, Func next) { var currentPrincipalAccessor = context.ServiceProvider.GetRequiredService(); - using (currentPrincipalAccessor.Change(context.Context.User!)) + using (currentPrincipalAccessor.Change((await GetDynamicClaimsPrincipalAsync(context.Context.User, context.ServiceProvider))!)) { await next(context); } @@ -29,9 +31,27 @@ public class AbpAuthenticationHubFilter : IHubFilter public virtual async Task OnDisconnectedAsync(HubLifetimeContext context, Exception? exception, Func next) { var currentPrincipalAccessor = context.ServiceProvider.GetRequiredService(); - using (currentPrincipalAccessor.Change(context.Context.User!)) + using (currentPrincipalAccessor.Change((await GetDynamicClaimsPrincipalAsync(context.Context.User, context.ServiceProvider))!)) { await next(context, exception); } } + + protected virtual async Task GetDynamicClaimsPrincipalAsync(ClaimsPrincipal? claimsPrincipal, IServiceProvider serviceProvider) + { + if (claimsPrincipal == null) + { + return claimsPrincipal; + } + + if (claimsPrincipal.Identity != null && + claimsPrincipal.Identity.IsAuthenticated && + serviceProvider.GetRequiredService>().Value.IsDynamicClaimsEnabled) + { + var abpClaimsPrincipalFactory = serviceProvider.GetRequiredService(); + claimsPrincipal = await abpClaimsPrincipalFactory.CreateDynamicAsync(claimsPrincipal); + } + + return claimsPrincipal; + } }