pull/892/head
Yunus Emre Kalkan 7 years ago
commit e1ea96a829

@ -17,6 +17,12 @@
<EmbeddedResource Include="Volo\Abp\Identity\Localization\Domain\*.json" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Volo\Abp\Permissions\**" />
<EmbeddedResource Remove="Volo\Abp\Permissions\**" />
<None Remove="Volo\Abp\Permissions\**" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.Identity.Domain.Shared\Volo.Abp.Identity.Domain.Shared.csproj" />
@ -29,8 +35,4 @@
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Volo\Abp\Permissions\" />
</ItemGroup>
</Project>

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Volo.Abp.DependencyInjection;
@ -53,7 +52,7 @@ namespace Volo.Abp.Identity
adminUser = new IdentityUser(_guidGenerator.Create(), adminUserName, "admin@abp.io", tenantId);
adminUser.Name = adminUserName;
CheckIdentityErrors(await _userManager.CreateAsync(adminUser, adminUserPassword));
(await _userManager.CreateAsync(adminUser, adminUserPassword)).CheckErrors();
result.CreatedAdminUser = true;
//"admin" role
@ -65,24 +64,13 @@ namespace Volo.Abp.Identity
adminRole.IsStatic = true;
adminRole.IsPublic = true;
CheckIdentityErrors(await _roleManager.CreateAsync(adminRole));
(await _roleManager.CreateAsync(adminRole)).CheckErrors();
result.CreatedAdminRole = true;
}
CheckIdentityErrors(await _userManager.AddToRoleAsync(adminUser, adminRoleName));
(await _userManager.AddToRoleAsync(adminUser, adminRoleName)).CheckErrors();
return result;
}
protected void CheckIdentityErrors(IdentityResult identityResult) //TODO: This is temporary and duplicate code!
{
if (!identityResult.Succeeded)
{
//TODO: A better exception that can be shown on UI as localized?
throw new AbpException("Operation failed: " + identityResult.Errors.Select(e => $"[{e.Code}] {e.Description}").JoinAsString(", "));
}
//identityResult.CheckErrors(LocalizationManager); //TODO: Get from old Abp
}
}
}

Loading…
Cancel
Save