Skip to content

Commit

Permalink
Fixed #2512: AccountAppService should check self registration setting
Browse files Browse the repository at this point in the history
  • Loading branch information
hikalkan committed Dec 30, 2019
1 parent 6312a18 commit fb4fe90
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Volo.Abp.Account.Web.Settings
namespace Volo.Abp.Account.Settings
{
public class AccountSettingNames
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Volo.Abp.Account.Settings;
using Volo.Abp.Application.Services;
using Volo.Abp.Identity;
using Volo.Abp.Settings;

namespace Volo.Abp.Account
{
Expand All @@ -17,11 +19,21 @@ public AccountAppService(

public virtual async Task<IdentityUserDto> RegisterAsync(RegisterDto input)
{
await CheckSelfRegistrationAsync().ConfigureAwait(false);

var user = new IdentityUser(GuidGenerator.Create(), input.UserName, input.EmailAddress, CurrentTenant.Id);

(await UserManager.CreateAsync(user, input.Password).ConfigureAwait(false)).CheckErrors();

return ObjectMapper.Map<IdentityUser, IdentityUserDto>(user);
}

protected virtual async Task CheckSelfRegistrationAsync()
{
if (!await SettingProvider.IsTrueAsync(AccountSettingNames.IsSelfRegistrationEnabled).ConfigureAwait(false))
{
throw new UserFriendlyException(L["SelfRegistrationDisabledMessage"]);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Volo.Abp.Localization;
using Volo.Abp.Settings;

namespace Volo.Abp.Account.Web.Settings
namespace Volo.Abp.Account.Settings
{
public class AccountSettingDefinitionProvider : SettingDefinitionProvider
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using System.Security.Claims;
using System.Security.Principal;
using System.Threading.Tasks;
using Volo.Abp.Account.Web.Settings;
using Volo.Abp.Account.Settings;
using Volo.Abp.DependencyInjection;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Settings;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page
@using Volo.Abp.Account.Web.Settings
@using Volo.Abp.Account.Settings
@model Volo.Abp.Account.Web.Pages.Account.LoginModel
@inherits Volo.Abp.Account.Web.Pages.Account.AccountPage
@inject Volo.Abp.Settings.ISettingProvider SettingProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Volo.Abp.Account.Web.Settings;
using Volo.Abp.Account.Settings;
using Volo.Abp.Identity;
using Volo.Abp.Security.Claims;
using Volo.Abp.Settings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Account.Web.Settings;
using Volo.Abp.Account.Settings;
using Volo.Abp.Settings;
using Volo.Abp.Uow;
using IdentityUser = Volo.Abp.Identity.IdentityUser;
Expand Down

0 comments on commit fb4fe90

Please sign in to comment.