Browse Source

Merge pull request #18375 from abpframework/auto-merge/rel-8-0/2320

Merge branch dev with rel-8.0
pull/18381/head
maliming 3 years ago
committed by GitHub
parent
commit
17a759a9b4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/ChangeThemeStep.cs
  2. 9
      modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs
  3. 18
      modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/SecurityStampValidatorOptionsExtensions.cs
  4. 41
      npm/ng-packs/packages/schematics/src/commands/change-theme/index.ts

3
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.LeptonX => "@volosoft/abp.ng.theme.lepton-x",
Theme.LeptonXLite => "@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", Theme.Basic => "@abp/ng.theme.basic",
_ => string.Empty _ => string.Empty
}; };
@ -783,4 +784,4 @@ public class ChangeThemeStep : ProjectBuildPipelineStep
Lepton Lepton
); );
} }
} }

9
modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs

@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using static Volo.Abp.Identity.AspNetCore.AbpSecurityStampValidatorCallback;
namespace Volo.Abp.Identity.AspNetCore; namespace Volo.Abp.Identity.AspNetCore;
@ -41,4 +42,12 @@ public class AbpIdentityAspNetCoreModule : AbpModule
.AddIdentityCookies(); .AddIdentityCookies();
} }
} }
public override void PostConfigureServices(ServiceConfigurationContext context)
{
Configure<SecurityStampValidatorOptions>(options =>
{
options.UpdatePrincipal();
});
}
} }

18
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;
}
}

41
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) => { return (host: Tree) => {
const recorder = host.beginUpdate(appModulePath); const recorder = host.beginUpdate(appModulePath);
const source = createSourceFile(host, appModulePath); const source = createSourceFile(host, appModulePath);
const impMap = getImportPaths(selectedTheme); const impMap = getImportPaths(selectedTheme, true);
const nodes = findNodes(source, ts.isImportDeclaration); 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) { if (filteredNodes?.length < 1) {
return; return;
} }
@ -106,7 +118,7 @@ export function removeImportFromNgModuleMetadata(
return (host: Tree) => { return (host: Tree) => {
const recorder = host.beginUpdate(appModulePath); const recorder = host.beginUpdate(appModulePath);
const source = createSourceFile(host, appModulePath); const source = createSourceFile(host, appModulePath);
const impMap = getImportPaths(selectedTheme); const impMap = getImportPaths(selectedTheme, true);
const node = getDecoratorMetadata(source, 'NgModule', '@angular/core')[0] || {}; const node = getDecoratorMetadata(source, 'NgModule', '@angular/core')[0] || {};
if (!node) { if (!node) {
@ -144,8 +156,13 @@ export function insertImports(appModulePath: string, selectedTheme: ThemeOptions
const source = createSourceFile(host, appModulePath); const source = createSourceFile(host, appModulePath);
const selected = importMap.get(selectedTheme); const selected = importMap.get(selectedTheme);
if (!selected) {
return host;
}
const changes: Change[] = []; const changes: Change[] = [];
selected!.map(({ importName, path }) =>
selected.map(({ importName, path }) =>
changes.push(...addImportToModule(source, appModulePath, 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 sourceText = buffer.toString('utf-8');
const source = ts.createSourceFile(
return ts.createSourceFile(
appModulePath, appModulePath,
sourceText, sourceText,
ts.ScriptTarget.Latest, ts.ScriptTarget.Latest,
true, true,
ts.ScriptKind.TS, 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()) return Array.from(importMap.values())
.filter(f => f !== importMap.get(selectedTheme)) .filter(f => f !== importMap.get(selectedTheme))
.reduce((acc, val) => [...acc, ...val], []); .reduce((acc, val) => [...acc, ...val], []);

Loading…
Cancel
Save