From dc480f1f6b2cf4f852f9dec223029402fbb03e18 Mon Sep 17 00:00:00 2001 From: colin Date: Thu, 17 Sep 2026 13:07:23 +0800 Subject: [PATCH] feat: Change the settings of the group --- .../Abp/Account/MyProfileAppService.cs | 2 +- .../LINGYUN/Abp/Identity/Localization/en.json | 10 ++++---- .../Abp/Identity/Localization/zh-Hans.json | 10 ++++---- .../Identity/Settings/IdentitySettingNames.cs | 12 +++++----- ...IdentityTwoFactorBehaviourSettingHelper.cs | 2 +- .../Abp/Identity/AbpIdentityUserStore.cs | 2 +- .../IdentityRoleDefaultRoleChangeHandler.cs | 2 +- .../Abp/Identity/IdentityTwoFactorManager.cs | 2 +- .../IdentitySettingDefinitionProvider.cs | 24 +++++++++---------- 9 files changed, 33 insertions(+), 33 deletions(-) diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/MyProfileAppService.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/MyProfileAppService.cs index dd94159d1..aff593b45 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/MyProfileAppService.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/MyProfileAppService.cs @@ -122,7 +122,7 @@ public class MyProfileAppService : AccountApplicationServiceBase, IMyProfileAppS public async virtual Task ChangeTwoFactorEnabledAsync(TwoFactorEnabledDto input) { - if (!await SettingProvider.IsTrueAsync(IdentitySettingNames.TwoFactor.UsersCanChange)) + if (!await SettingProvider.IsTrueAsync(IdentitySettingNames.Security.UsersCanChangeTwoFactor)) { throw new BusinessException( Volo.Abp.Identity.IdentityErrorCodes.CanNotChangeTwoFactor, diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Localization/en.json b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Localization/en.json index 5f2727c8b..db909bc8b 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Localization/en.json +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Localization/en.json @@ -78,10 +78,10 @@ "Description:Abp.Identity.Link.UserLoginUri": "Set up a user login link for redirecting external authenticated users.", "DisplayName:Abp.Identity.TwoFactorBehaviour": "Two Factor behaviour", "Description:Abp.Identity.TwoFactorBehaviour": "Two Factor behaviour", - "DisplayName:Abp.Identity.UsersCanChange": "Allow users to change their Two Factor.", - "Description:Abp.Identity.UsersCanChange": "Allow users to change their Two Factor.", - "DisplayName:Abp.Identity.AdminRoleForceEnabled": "Administrator role is forcibly enabled", - "Description:Abp.Identity.AdminRoleForceEnabled": "The administrator role is required to use secondary authentication when logging in.", + "DisplayName:Abp.Identity.UsersCanChangeTwoFactor": "Allow users to change their Two Factor.", + "Description:Abp.Identity.UsersCanChangeTwoFactor": "Allow users to change their Two Factor.", + "DisplayName:Abp.Identity.AdminRoleTwoFactorForceEnabled": "Admin role is forcibly enabled TFA", + "Description:Abp.Identity.AdminRoleTwoFactorForceEnabled": "The administrator role is required to use TFA when logging in.", "DisplayName:Abp.Identity.ProhibitDefaultAdminRole": "Prohibit the setting of the default admin role", "Description:Abp.Identity.ProhibitDefaultAdminRole": "It is not allowed to set the administrator role (admin) as the default role.", "DisplayName:Identity.Link": "Link", @@ -140,7 +140,7 @@ "Settings:Identity.OrganizationUnit": "OrganizationUnit", "Settings:Identity.Session": "Session", "Settings:Identity.Link": "Link", - "Settings:Identity.TwoFactor": "TwoFactor", + "Settings:Identity.Security": "Security", "ImpersonationUser": "Impersonation", "Features:Identity": "Identity", "Features:Identity.TwoFactor": "Two factor behaviour", diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Localization/zh-Hans.json b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Localization/zh-Hans.json index bba683cae..1f7ac1679 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Localization/zh-Hans.json +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Localization/zh-Hans.json @@ -78,10 +78,10 @@ "Description:Abp.Identity.Link.UserLoginUri": "设置用户登录链接,用于外部认证用户重定向.", "DisplayName:Abp.Identity.TwoFactorBehaviour": "双因素身份验证行为", "Description:Abp.Identity.TwoFactorBehaviour": "双因素身份验证行为", - "DisplayName:Abp.Identity.UsersCanChange": "允许用户更改其因素身份验证", - "Description:Abp.Identity.UsersCanChange": "允许用户更改其因素身份验证.", - "DisplayName:Abp.Identity.AdminRoleForceEnabled": "管理员角色强制启用", - "Description:Abp.Identity.AdminRoleForceEnabled": "管理员角色登录时强制使用二次认证.", + "DisplayName:Abp.Identity.UsersCanChangeTwoFactor": "允许用户更改其因素身份验证", + "Description:Abp.Identity.UsersCanChangeTwoFactor": "允许用户更改其因素身份验证.", + "DisplayName:Abp.Identity.AdminRoleTwoFactorForceEnabled": "管理员角色强制启用二次认证", + "Description:Abp.Identity.AdminRoleTwoFactorForceEnabled": "管理员角色登录时强制使用二次认证.", "DisplayName:Abp.Identity.ProhibitDefaultAdminRole": "禁止设置管理员默认角色", "Description:Abp.Identity.ProhibitDefaultAdminRole": "不允许将管理员角色(admin)设置为默认角色.", "DisplayName:Identity.Link": "链接", @@ -140,7 +140,7 @@ "Settings:Identity.OrganizationUnit": "组织机构", "Settings:Identity.Session": "会话配置", "Settings:Identity.Link": "链接", - "Settings:Identity.TwoFactor": "二次认证", + "Settings:Identity.Security": "安全配置", "ImpersonationUser": "模拟用户", "Features:Identity": "身份认证", "Features:Identity.TwoFactor": "双因素身份验证行为", diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Settings/IdentitySettingNames.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Settings/IdentitySettingNames.cs index cefba4da5..a1845fa1f 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Settings/IdentitySettingNames.cs +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Settings/IdentitySettingNames.cs @@ -46,17 +46,17 @@ public static class IdentitySettingNames public const string LogoutFromSameTypeDevicesLimit = SessionPrefix + ".LogoutFromSameTypeDevicesLimit"; } - public static class TwoFactor + public static class Security { - private const string TwoFactorPrefix = Prefix + ".TwoFactor"; + private const string SecurityPrefix = Prefix + ".Security"; - public const string Behaviour = TwoFactorPrefix + ".Behaviour"; + public const string TwoFactorBehaviour = SecurityPrefix + ".TwoFactorBehaviour"; - public const string UsersCanChange = TwoFactorPrefix + ".UsersCanChange"; + public const string UsersCanChangeTwoFactor = SecurityPrefix + ".UsersCanChangeTwoFactor"; - public const string AdminRoleForceEnabled = TwoFactorPrefix + ".AdminRoleForceEnabled"; + public const string AdminRoleTwoFactorForceEnabled = SecurityPrefix + ".AdminRoleTwoFactorForceEnabled"; - public const string ProhibitDefaultAdminRole = TwoFactorPrefix + ".ProhibitDefaultAdminRole"; + public const string ProhibitDefaultAdminRole = SecurityPrefix + ".ProhibitDefaultAdminRole"; } public static class Link diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Settings/IdentityTwoFactorBehaviourSettingHelper.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Settings/IdentityTwoFactorBehaviourSettingHelper.cs index f3dbbc876..5ec884cf5 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Settings/IdentityTwoFactorBehaviourSettingHelper.cs +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Settings/IdentityTwoFactorBehaviourSettingHelper.cs @@ -12,7 +12,7 @@ public static class IdentityTwoFactorBehaviourSettingHelper { Check.NotNull(settingProvider, nameof(settingProvider)); - var value = await settingProvider.GetOrNullAsync(IdentitySettingNames.TwoFactor.Behaviour); + var value = await settingProvider.GetOrNullAsync(IdentitySettingNames.Security.TwoFactorBehaviour); if (!value.IsNullOrWhiteSpace() && Enum.TryParse(value, out var behaviour)) { return behaviour; diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/AbpIdentityUserStore.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/AbpIdentityUserStore.cs index 6ba3136a5..0434478bf 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/AbpIdentityUserStore.cs +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/AbpIdentityUserStore.cs @@ -46,7 +46,7 @@ public class AbpIdentityUserStore : IdentityUserStore if (!user.TwoFactorEnabled && await IsInRoleAsync(user, AbpRoleConsts.AdminRoleName, cancellationToken) && - await SettingProvider.IsTrueAsync(IdentitySettingNames.TwoFactor.AdminRoleForceEnabled)) + await SettingProvider.IsTrueAsync(IdentitySettingNames.Security.AdminRoleTwoFactorForceEnabled)) { await SetTwoFactorEnabledAsync(user, true, cancellationToken); } diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/IdentityRoleDefaultRoleChangeHandler.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/IdentityRoleDefaultRoleChangeHandler.cs index 0d292eeec..419481dba 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/IdentityRoleDefaultRoleChangeHandler.cs +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/IdentityRoleDefaultRoleChangeHandler.cs @@ -23,7 +23,7 @@ public class IdentityRoleDefaultRoleChangeHandler : public async virtual Task HandleEventAsync(EntityChangedEventData eventData) { if (eventData.Entity.Name.Equals(AbpRoleConsts.AdminRoleName, StringComparison.CurrentCultureIgnoreCase) && - await SettingProvider.IsTrueAsync(IdentitySettingNames.TwoFactor.ProhibitDefaultAdminRole)) + await SettingProvider.IsTrueAsync(IdentitySettingNames.Security.ProhibitDefaultAdminRole)) { throw new BusinessException( IdentityErrorCodes.ProhibitSetDefaultAdminRole, diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/IdentityTwoFactorManager.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/IdentityTwoFactorManager.cs index 6c995f0e7..f7a3da820 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/IdentityTwoFactorManager.cs +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/IdentityTwoFactorManager.cs @@ -81,7 +81,7 @@ public class IdentityTwoFactorManager : DomainService return true; } - if (isInAdminRole && await SettingProvider.IsTrueAsync(IdentitySettingNames.TwoFactor.AdminRoleForceEnabled)) + if (isInAdminRole && await SettingProvider.IsTrueAsync(IdentitySettingNames.Security.AdminRoleTwoFactorForceEnabled)) { return true; } diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Settings/IdentitySettingDefinitionProvider.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Settings/IdentitySettingDefinitionProvider.cs index cdbfd045f..cdd58c583 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Settings/IdentitySettingDefinitionProvider.cs +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Settings/IdentitySettingDefinitionProvider.cs @@ -115,7 +115,7 @@ public class IdentitySettingDefinitionProvider : SettingDefinitionProvider .WithValueType(ValueType.Number), new SettingDefinition( - name: IdentitySettingNames.TwoFactor.Behaviour, + name: IdentitySettingNames.Security.TwoFactorBehaviour, defaultValue: IdentityTwoFactorBehaviour.Optional.ToString(), displayName: L("DisplayName:Abp.Identity.TwoFactorBehaviour"), description: L("Description:Abp.Identity.TwoFactorBehaviour"), @@ -126,7 +126,7 @@ public class IdentitySettingDefinitionProvider : SettingDefinitionProvider GlobalSettingValueProvider.ProviderName, TenantSettingValueProvider.ProviderName) .WithGroup(GroupName, L("Settings:Identity"), GroupOrder) - .WithParent("TwoFactor", L("Settings:Identity.TwoFactor"), order: 5) + .WithParent("Security", L("Settings:Identity.Security"), order: 5) .WithOrder(0) .WithOptions([ new NameValue(stringLocalizer["IdentityTwoFactorBehaviour:Optional"].Value, IdentityTwoFactorBehaviour.Optional.ToString()), @@ -134,10 +134,10 @@ public class IdentitySettingDefinitionProvider : SettingDefinitionProvider new NameValue(stringLocalizer["IdentityTwoFactorBehaviour:Forced"].Value, IdentityTwoFactorBehaviour.Forced.ToString()), ]), new SettingDefinition( - name: IdentitySettingNames.TwoFactor.UsersCanChange, + name: IdentitySettingNames.Security.UsersCanChangeTwoFactor, defaultValue: true.ToString(), - displayName: L("DisplayName:Abp.Identity.UsersCanChange"), - description: L("Description:Abp.Identity.UsersCanChange"), + displayName: L("DisplayName:Abp.Identity.UsersCanChangeTwoFactor"), + description: L("Description:Abp.Identity.UsersCanChangeTwoFactor"), isVisibleToClients: true) .WithProviders( DefaultValueSettingValueProvider.ProviderName, @@ -145,14 +145,14 @@ public class IdentitySettingDefinitionProvider : SettingDefinitionProvider GlobalSettingValueProvider.ProviderName, TenantSettingValueProvider.ProviderName) .WithGroup(GroupName, L("Settings:Identity"), GroupOrder) - .WithParent("TwoFactor", L("Settings:Identity.TwoFactor"), order: 5) + .WithParent("Security", L("Settings:Identity.Security"), order: 5) .WithOrder(1) .WithValueType(ValueType.Boolean), new SettingDefinition( - name: IdentitySettingNames.TwoFactor.AdminRoleForceEnabled, + name: IdentitySettingNames.Security.AdminRoleTwoFactorForceEnabled, defaultValue: true.ToString(), - displayName: L("DisplayName:Abp.Identity.AdminRoleForceEnabled"), - description: L("Description:Abp.Identity.AdminRoleForceEnabled"), + displayName: L("DisplayName:Abp.Identity.AdminRoleTwoFactorForceEnabled"), + description: L("Description:Abp.Identity.AdminRoleTwoFactorForceEnabled"), isVisibleToClients: false) .WithProviders( DefaultValueSettingValueProvider.ProviderName, @@ -160,11 +160,11 @@ public class IdentitySettingDefinitionProvider : SettingDefinitionProvider GlobalSettingValueProvider.ProviderName, TenantSettingValueProvider.ProviderName) .WithGroup(GroupName, L("Settings:Identity"), GroupOrder) - .WithParent("TwoFactor", L("Settings:Identity.TwoFactor"), order: 5) + .WithParent("Security", L("Settings:Identity.Security"), order: 5) .WithOrder(2) .WithValueType(ValueType.Boolean), new SettingDefinition( - name: IdentitySettingNames.TwoFactor.ProhibitDefaultAdminRole, + name: IdentitySettingNames.Security.ProhibitDefaultAdminRole, defaultValue: true.ToString(), displayName: L("DisplayName:Abp.Identity.ProhibitDefaultAdminRole"), description: L("Description:Abp.Identity.ProhibitDefaultAdminRole"), @@ -175,7 +175,7 @@ public class IdentitySettingDefinitionProvider : SettingDefinitionProvider GlobalSettingValueProvider.ProviderName, TenantSettingValueProvider.ProviderName) .WithGroup(GroupName, L("Settings:Identity"), GroupOrder) - .WithParent("TwoFactor", L("Settings:Identity.TwoFactor"), order: 5) + .WithParent("Security", L("Settings:Identity.Security"), order: 5) .WithOrder(3) .WithValueType(ValueType.Boolean),