From 7c8171b2ee8495bf0dece4ba6c0a53e2a3ed236f Mon Sep 17 00:00:00 2001 From: masumulu28 Date: Tue, 5 Dec 2023 10:57:33 +0300 Subject: [PATCH 1/4] fix module find condition, included module name bisde module path --- .../src/commands/change-theme/index.ts | 41 +++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/npm/ng-packs/packages/schematics/src/commands/change-theme/index.ts b/npm/ng-packs/packages/schematics/src/commands/change-theme/index.ts index d3a28876ba..f524f705fa 100644 --- a/npm/ng-packs/packages/schematics/src/commands/change-theme/index.ts +++ b/npm/ng-packs/packages/schematics/src/commands/change-theme/index.ts @@ -81,11 +81,23 @@ export function removeImportPath(appModulePath: string, selectedTheme: ThemeOpti return (host: Tree) => { const recorder = host.beginUpdate(appModulePath); const source = createSourceFile(host, appModulePath); - const impMap = getImportPaths(selectedTheme); + const impMap = getImportPaths(selectedTheme, true); const nodes = findNodes(source, ts.isImportDeclaration); - const filteredNodes = nodes.filter(n => impMap.some(f => n.getFullText().match(f.path))); + const filteredNodes = nodes.filter(node => + impMap.some(({ path, importName }) => { + const sourceModule = node.getFullText(); + const moduleName = importName.split('.')[0]; + + if (path && sourceModule.match(path)) { + return true; + } + + return !!(moduleName && sourceModule.match(moduleName)); + }), + ); + if (filteredNodes?.length < 1) { return; } @@ -106,7 +118,7 @@ export function removeImportFromNgModuleMetadata( return (host: Tree) => { const recorder = host.beginUpdate(appModulePath); const source = createSourceFile(host, appModulePath); - const impMap = getImportPaths(selectedTheme); + const impMap = getImportPaths(selectedTheme, true); const node = getDecoratorMetadata(source, 'NgModule', '@angular/core')[0] || {}; if (!node) { @@ -144,8 +156,13 @@ export function insertImports(appModulePath: string, selectedTheme: ThemeOptions const source = createSourceFile(host, appModulePath); const selected = importMap.get(selectedTheme); + if (!selected) { + return host; + } + const changes: Change[] = []; - selected!.map(({ importName, path }) => + + selected.map(({ importName, path }) => changes.push(...addImportToModule(source, appModulePath, importName, path)), ); @@ -168,18 +185,26 @@ export function createSourceFile(host: Tree, appModulePath: string): ts.SourceFi } const sourceText = buffer.toString('utf-8'); - const source = ts.createSourceFile( + + return ts.createSourceFile( appModulePath, sourceText, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS, ); - - return source; } -export function getImportPaths(selectedTheme: ThemeOptionsEnum) { +/** + * Returns all import paths except the selected theme + * @param selectedTheme The selected theme + * @param getAll If true, returns all import paths + */ +export function getImportPaths(selectedTheme: ThemeOptionsEnum, getAll: boolean = false) { + if (getAll) { + return Array.from(importMap.values()).reduce((acc, val) => [...acc, ...val], []); + } + return Array.from(importMap.values()) .filter(f => f !== importMap.get(selectedTheme)) .reduce((acc, val) => [...acc, ...val], []); From 05f685b8088643af50483ce5047bc3a16f751490 Mon Sep 17 00:00:00 2001 From: selman koc <64414348+skoc10@users.noreply.github.com> Date: Tue, 5 Dec 2023 12:02:07 +0300 Subject: [PATCH 2/4] Update version to release 7.4.3 --- common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.props b/common.props index e7ecc39b83..091ef7de3f 100644 --- a/common.props +++ b/common.props @@ -1,7 +1,7 @@ latest - 7.4.2 + 7.4.3 $(NoWarn);CS1591;CS0436 https://abp.io/assets/abp_nupkg.png https://abp.io/ From 07ab77781432ca231bd7ee333d8bcefa6b3db983 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 6 Dec 2023 19:07:16 +0800 Subject: [PATCH 3/4] Keep the claims when refreshing principal --- .../AspNetCore/AbpIdentityAspNetCoreModule.cs | 9 +++++++++ .../SecurityStampValidatorOptionsExtensions.cs | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/SecurityStampValidatorOptionsExtensions.cs 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 974f81a201..9b38e2e25a 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 @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Modularity; +using static Volo.Abp.Identity.AspNetCore.AbpSecurityStampValidatorCallback; namespace Volo.Abp.Identity.AspNetCore; @@ -41,4 +42,12 @@ public class AbpIdentityAspNetCoreModule : AbpModule .AddIdentityCookies(); } } + + public override void PostConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.UpdatePrincipal(); + }); + } } diff --git a/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/SecurityStampValidatorOptionsExtensions.cs b/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/SecurityStampValidatorOptionsExtensions.cs new file mode 100644 index 0000000000..4d1a26b03c --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/SecurityStampValidatorOptionsExtensions.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Identity; +using static Volo.Abp.Identity.AspNetCore.AbpSecurityStampValidatorCallback; + +namespace Volo.Abp.Identity.AspNetCore; + +public static class SecurityStampValidatorOptionsExtensions +{ + public static SecurityStampValidatorOptions UpdatePrincipal(this SecurityStampValidatorOptions options) + { + var previousOnRefreshingPrincipal = options.OnRefreshingPrincipal; + options.OnRefreshingPrincipal = async context => + { + await SecurityStampValidatorCallback.UpdatePrincipal(context); + await previousOnRefreshingPrincipal?.Invoke(context); + }; + return options; + } +} From 47b768af5f3779b3e3ff15b0a5d914194eda71a3 Mon Sep 17 00:00:00 2001 From: Engincan VESKE Date: Tue, 5 Dec 2023 16:06:57 +0300 Subject: [PATCH 4/4] Update ChangeThemeStep.cs --- .../Abp/Cli/ProjectBuilding/Building/Steps/ChangeThemeStep.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/ChangeThemeStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/ChangeThemeStep.cs index 73e33211e3..b6408fb3e2 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/ChangeThemeStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/ChangeThemeStep.cs @@ -66,6 +66,7 @@ public class ChangeThemeStep : ProjectBuildPipelineStep { Theme.LeptonX => "@volosoft/abp.ng.theme.lepton-x", Theme.LeptonXLite => "@abp/ng.theme.lepton-x", + Theme.Lepton => "@volo/abp.ng.theme.lepton", Theme.Basic => "@abp/ng.theme.basic", _ => string.Empty }; @@ -783,4 +784,4 @@ public class ChangeThemeStep : ProjectBuildPipelineStep Lepton ); } -} \ No newline at end of file +}