Skip to content

Commit ac81616

Browse files
committed
Check errors for IdentityResults.
1 parent f48d2eb commit ac81616

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

aspnet-core/src/AbpCompanyName.AbpProjectName.Application/MultiTenancy/TenantAppService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public async Task CreateTenant(CreateTenantInput input)
7272
using (CurrentUnitOfWork.SetTenantId(tenant.Id))
7373
{
7474
//Create static roles for new tenant
75-
await _roleManager.CreateStaticRoles(tenant.Id);
75+
CheckErrors(await _roleManager.CreateStaticRoles(tenant.Id));
7676

7777
await CurrentUnitOfWork.SaveChangesAsync(); //To get static role ids
7878

@@ -83,11 +83,11 @@ public async Task CreateTenant(CreateTenantInput input)
8383
//Create admin user for the tenant
8484
var adminUser = User.CreateTenantAdminUser(tenant.Id, input.AdminEmailAddress);
8585
adminUser.Password = _passwordHasher.HashPassword(adminUser, User.DefaultPassword);
86-
await UserManager.CreateAsync(adminUser);
86+
CheckErrors(await UserManager.CreateAsync(adminUser));
8787
await CurrentUnitOfWork.SaveChangesAsync(); //To get admin user's id
8888

8989
//Assign admin user to role!
90-
await UserManager.AddToRoleAsync(adminUser, adminRole.Name);
90+
CheckErrors(await UserManager.AddToRoleAsync(adminUser, adminRole.Name));
9191
await CurrentUnitOfWork.SaveChangesAsync();
9292
}
9393
}

aspnet-core/src/AbpCompanyName.AbpProjectName.Application/Users/UserAppService.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Threading.Tasks;
33
using Abp.Application.Services.Dto;
44
using Abp.Authorization;
5-
using Abp.AutoMapper;
65
using Abp.Domain.Repositories;
76
using AbpCompanyName.AbpProjectName.Authorization;
87
using AbpCompanyName.AbpProjectName.Authorization.Users;
@@ -41,7 +40,7 @@ public async Task ProhibitPermission(ProhibitPermissionInput input)
4140
public async Task RemoveFromRole(long userId, string roleName)
4241
{
4342
var user = await UserManager.FindByIdAsync(userId.ToString());
44-
await UserManager.RemoveFromRoleAsync(user, roleName);
43+
CheckErrors(await UserManager.RemoveFromRoleAsync(user, roleName));
4544
}
4645

4746
public async Task<ListResultDto<UserListDto>> GetUsers()
@@ -61,7 +60,7 @@ public async Task CreateUser(CreateUserInput input)
6160
user.Password = _passwordHasher.HashPassword(user, input.Password);
6261
user.IsEmailConfirmed = true;
6362

64-
await UserManager.CreateAsync(user);
63+
CheckErrors(await UserManager.CreateAsync(user));
6564
}
6665
}
6766
}

0 commit comments

Comments
 (0)