You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.7 KiB
43 lines
1.7 KiB
2 years ago
|
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<ISettingManager>();
|
||
|
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<ISettingManager>();
|
||
|
|
||
|
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);
|
||
|
}
|
||
|
}
|