using System; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Identity.Settings; using Volo.Abp.SettingManagement; namespace Win_in.Sfs.Shared.Domain.Shared; public static class SettingsExtensions { public static void InitSettings(this IServiceProvider services) { InitSettingsAsync(services).GetAwaiter().GetResult(); } private static async Task InitSettingsAsync(IServiceProvider services) { var settingManager = services.GetRequiredService(); var settings = await settingManager.GetAllGlobalAsync().ConfigureAwait(false); foreach (var setting in settings) { await settingManager.SetAsync(setting.Name, setting.Value, "G", null, true).ConfigureAwait(false); } } public static void SetPasswordRules(this IServiceProvider services) { SetPasswordRulesAsync(services).GetAwaiter().GetResult(); } public static async Task SetPasswordRulesAsync(IServiceProvider services) { var settingManager = services.GetRequiredService(); await settingManager.SetGlobalAsync(IdentitySettingNames.Password.RequireDigit, "true").ConfigureAwait(false); await settingManager.SetGlobalAsync(IdentitySettingNames.Password.RequireLowercase, "false").ConfigureAwait(false); await settingManager.SetGlobalAsync(IdentitySettingNames.Password.RequireNonAlphanumeric, "false").ConfigureAwait(false); await settingManager.SetGlobalAsync(IdentitySettingNames.Password.RequireUppercase, "false").ConfigureAwait(false); await settingManager.SetGlobalAsync(IdentitySettingNames.Password.RequiredLength, "6").ConfigureAwait(false); } }