Browse Source

Fixed #2512: AccountAppService should check self registration setting

pull/2521/head
Halil İbrahim Kalkan 7 years ago
parent
commit
fb4fe908b5
  1. 2
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Settings/AccountSettingNames.cs
  2. 12
      modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AccountAppService.cs
  3. 2
      modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/Settings/AccountSettingDefinitionProvider.cs
  4. 2
      modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs
  5. 2
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml
  6. 2
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs
  7. 2
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs

2
modules/account/src/Volo.Abp.Account.Web/Settings/AccountSettingNames.cs → modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Settings/AccountSettingNames.cs

@ -1,4 +1,4 @@
namespace Volo.Abp.Account.Web.Settings
namespace Volo.Abp.Account.Settings
{
public class AccountSettingNames
{

12
modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AccountAppService.cs

@ -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
{
@ -17,11 +19,21 @@ namespace Volo.Abp.Account
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"]);
}
}
}
}

2
modules/account/src/Volo.Abp.Account.Web/Settings/AccountSettingDefinitionProvider.cs → modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/Settings/AccountSettingDefinitionProvider.cs

@ -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
{

2
modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs

@ -12,7 +12,7 @@ using System.Linq;
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;

2
modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml

@ -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

2
modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs

@ -10,7 +10,7 @@ using System.Diagnostics;
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;

2
modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs

@ -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;

Loading…
Cancel
Save