using Elsa.Extensions;
using Elsa.Features.Abstractions;
using Elsa.Features.Attributes;
using Elsa.Features.Services;
using Elsa.Identity.HostedServices;
using Elsa.Identity.Options;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Identity.Features;
///
/// Feature that initializes an admin user from configuration if provided.
///
[DependsOn(typeof(IdentityFeature))]
[UsedImplicitly]
public class DefaultAdminUserFeature(IModule module) : FeatureBase(module)
{
public DefaultAdminUserFeature WithAdminUserName(string value)
{
Services.Configure(options => options.AdminUserName = value);
return this;
}
public DefaultAdminUserFeature WithAdminPassword(string value)
{
Services.Configure(options => options.AdminPassword = value);
return this;
}
public DefaultAdminUserFeature WithAdminRoleName(string value)
{
Services.Configure(options => options.AdminRoleName = value);
return this;
}
public DefaultAdminUserFeature WithAdminRolePermissions(ICollection value)
{
Services.Configure(options => options.AdminRolePermissions = value);
return this;
}
public override void Apply()
{
Services.AddBackgroundTask();
}
}