| | | 1 | | using Elsa.Extensions; |
| | | 2 | | using Elsa.Features.Abstractions; |
| | | 3 | | using Elsa.Features.Attributes; |
| | | 4 | | using Elsa.Features.Services; |
| | | 5 | | using Elsa.Identity.HostedServices; |
| | | 6 | | using Elsa.Identity.Options; |
| | | 7 | | using JetBrains.Annotations; |
| | | 8 | | using Microsoft.Extensions.DependencyInjection; |
| | | 9 | | |
| | | 10 | | namespace Elsa.Identity.Features; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Feature that initializes an admin user from configuration if provided. |
| | | 14 | | /// </summary> |
| | | 15 | | [DependsOn(typeof(IdentityFeature))] |
| | | 16 | | [UsedImplicitly] |
| | 0 | 17 | | public class DefaultAdminUserFeature(IModule module) : FeatureBase(module) |
| | | 18 | | { |
| | | 19 | | public DefaultAdminUserFeature WithAdminUserName(string value) |
| | | 20 | | { |
| | 0 | 21 | | Services.Configure<DefaultAdminUserOptions>(options => options.AdminUserName = value); |
| | 0 | 22 | | return this; |
| | | 23 | | } |
| | | 24 | | |
| | | 25 | | public DefaultAdminUserFeature WithAdminPassword(string value) |
| | | 26 | | { |
| | 0 | 27 | | Services.Configure<DefaultAdminUserOptions>(options => options.AdminPassword = value); |
| | 0 | 28 | | return this; |
| | | 29 | | } |
| | | 30 | | |
| | | 31 | | public DefaultAdminUserFeature WithAdminRoleName(string value) |
| | | 32 | | { |
| | 0 | 33 | | Services.Configure<DefaultAdminUserOptions>(options => options.AdminRoleName = value); |
| | 0 | 34 | | return this; |
| | | 35 | | } |
| | | 36 | | |
| | | 37 | | public DefaultAdminUserFeature WithAdminRolePermissions(ICollection<string> value) |
| | | 38 | | { |
| | 0 | 39 | | Services.Configure<DefaultAdminUserOptions>(options => options.AdminRolePermissions = value); |
| | 0 | 40 | | return this; |
| | | 41 | | } |
| | | 42 | | |
| | | 43 | | public override void Apply() |
| | | 44 | | { |
| | 0 | 45 | | Services.AddBackgroundTask<AdminUserInitializer>(); |
| | 0 | 46 | | } |
| | | 47 | | } |