|
|
@ -1,7 +1,9 @@ |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using Microsoft.AspNetCore.Identity; |
|
|
using Microsoft.AspNetCore.Identity; |
|
|
|
|
|
using Volo.Abp.Account.Settings; |
|
|
using Volo.Abp.Application.Services; |
|
|
using Volo.Abp.Application.Services; |
|
|
using Volo.Abp.Identity; |
|
|
using Volo.Abp.Identity; |
|
|
|
|
|
using Volo.Abp.Settings; |
|
|
|
|
|
|
|
|
namespace Volo.Abp.Account |
|
|
namespace Volo.Abp.Account |
|
|
{ |
|
|
{ |
|
|
@ -17,11 +19,21 @@ namespace Volo.Abp.Account |
|
|
|
|
|
|
|
|
public virtual async Task<IdentityUserDto> RegisterAsync(RegisterDto input) |
|
|
public virtual async Task<IdentityUserDto> RegisterAsync(RegisterDto input) |
|
|
{ |
|
|
{ |
|
|
|
|
|
await CheckSelfRegistrationAsync().ConfigureAwait(false); |
|
|
|
|
|
|
|
|
var user = new IdentityUser(GuidGenerator.Create(), input.UserName, input.EmailAddress, CurrentTenant.Id); |
|
|
var user = new IdentityUser(GuidGenerator.Create(), input.UserName, input.EmailAddress, CurrentTenant.Id); |
|
|
|
|
|
|
|
|
(await UserManager.CreateAsync(user, input.Password).ConfigureAwait(false)).CheckErrors(); |
|
|
(await UserManager.CreateAsync(user, input.Password).ConfigureAwait(false)).CheckErrors(); |
|
|
|
|
|
|
|
|
return ObjectMapper.Map<IdentityUser, IdentityUserDto>(user); |
|
|
return ObjectMapper.Map<IdentityUser, IdentityUserDto>(user); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual async Task CheckSelfRegistrationAsync() |
|
|
|
|
|
{ |
|
|
|
|
|
if (!await SettingProvider.IsTrueAsync(AccountSettingNames.IsSelfRegistrationEnabled).ConfigureAwait(false)) |
|
|
|
|
|
{ |
|
|
|
|
|
throw new UserFriendlyException(L["SelfRegistrationDisabledMessage"]); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|