Browse Source
Merge pull request #20131 from abpframework/identityseed
Add IdentityDataSeedContributor.AdminUsernamePropertyName
pull/20132/head
Engincan VESKE
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
12 additions and
4 deletions
-
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityDataSeeder.cs
-
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeedContributor.cs
-
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeeder.cs
|
|
|
@ -9,5 +9,6 @@ public interface IIdentityDataSeeder |
|
|
|
Task<IdentityDataSeedResult> SeedAsync( |
|
|
|
[NotNull] string adminEmail, |
|
|
|
[NotNull] string adminPassword, |
|
|
|
Guid? tenantId = null); |
|
|
|
Guid? tenantId = null, |
|
|
|
string? adminUserName = null); |
|
|
|
} |
|
|
|
|
|
|
|
@ -8,6 +8,8 @@ public class IdentityDataSeedContributor : IDataSeedContributor, ITransientDepen |
|
|
|
{ |
|
|
|
public const string AdminEmailPropertyName = "AdminEmail"; |
|
|
|
public const string AdminEmailDefaultValue = "admin@abp.io"; |
|
|
|
public const string AdminUserNamePropertyName = "AdminUserName"; |
|
|
|
public const string AdminUserNameDefaultValue = "admin"; |
|
|
|
public const string AdminPasswordPropertyName = "AdminPassword"; |
|
|
|
public const string AdminPasswordDefaultValue = "1q2w3E*"; |
|
|
|
|
|
|
|
@ -23,7 +25,8 @@ public class IdentityDataSeedContributor : IDataSeedContributor, ITransientDepen |
|
|
|
return IdentityDataSeeder.SeedAsync( |
|
|
|
context?[AdminEmailPropertyName] as string ?? AdminEmailDefaultValue, |
|
|
|
context?[AdminPasswordPropertyName] as string ?? AdminPasswordDefaultValue, |
|
|
|
context?.TenantId |
|
|
|
context?.TenantId, |
|
|
|
context?[AdminUserNamePropertyName] as string ?? AdminUserNameDefaultValue |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -44,7 +44,8 @@ public class IdentityDataSeeder : ITransientDependency, IIdentityDataSeeder |
|
|
|
public virtual async Task<IdentityDataSeedResult> SeedAsync( |
|
|
|
string adminEmail, |
|
|
|
string adminPassword, |
|
|
|
Guid? tenantId = null) |
|
|
|
Guid? tenantId = null, |
|
|
|
string? adminUserName = null) |
|
|
|
{ |
|
|
|
Check.NotNullOrWhiteSpace(adminEmail, nameof(adminEmail)); |
|
|
|
Check.NotNullOrWhiteSpace(adminPassword, nameof(adminPassword)); |
|
|
|
@ -55,7 +56,10 @@ public class IdentityDataSeeder : ITransientDependency, IIdentityDataSeeder |
|
|
|
|
|
|
|
var result = new IdentityDataSeedResult(); |
|
|
|
//"admin" user
|
|
|
|
const string adminUserName = "admin"; |
|
|
|
if(adminUserName.IsNullOrWhiteSpace()) |
|
|
|
{ |
|
|
|
adminUserName = IdentityDataSeedContributor.AdminUserNameDefaultValue; |
|
|
|
} |
|
|
|
var adminUser = await UserRepository.FindByNormalizedUserNameAsync( |
|
|
|
LookupNormalizer.NormalizeName(adminUserName) |
|
|
|
); |
|
|
|
|