From 7e0fd93bebad4976070b5c8fa8e31645f8750e54 Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 15 Nov 2019 15:04:03 +0800 Subject: [PATCH] Add Abp.Account.EnableLocalLogin setting. --- .../Pages/Account/IdentityServerSupportedLoginModel.cs | 6 ++++-- .../Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs | 8 +++++--- .../Settings/AccountSettingDefinitionProvider.cs | 4 ++++ .../Volo.Abp.Account.Web/Settings/AccountSettingNames.cs | 2 ++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs index 0714d5b323..f1abf44750 100644 --- a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs +++ b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs @@ -12,8 +12,10 @@ using System.Linq; using System.Security.Claims; using System.Security.Principal; using System.Threading.Tasks; +using Volo.Abp.Account.Web.Settings; using Volo.Abp.DependencyInjection; using Volo.Abp.MultiTenancy; +using Volo.Abp.Settings; using Volo.Abp.Uow; namespace Volo.Abp.Account.Web.Pages.Account @@ -77,7 +79,7 @@ namespace Volo.Abp.Account.Web.Pages.Account }) .ToList(); - EnableLocalLogin = true; //TODO: We can get default from a setting? + EnableLocalLogin = await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin); if (context?.ClientId != null) { var client = await ClientStore.FindEnabledClientByIdAsync(context.ClientId); @@ -105,7 +107,7 @@ namespace Volo.Abp.Account.Web.Pages.Account [UnitOfWork] //TODO: Will be removed when we implement action filter public override async Task OnPostAsync(string action) { - EnableLocalLogin = true; //TODO: We can get default from a setting? + EnableLocalLogin = await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin); if (action == "Cancel") { diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs index 74691dba33..e7e625416a 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs @@ -10,8 +10,10 @@ using System.Diagnostics; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; +using Volo.Abp.Account.Web.Settings; using Volo.Abp.Identity; using Volo.Abp.Security.Claims; +using Volo.Abp.Settings; using Volo.Abp.Uow; using Volo.Abp.Validation; using IdentityUser = Volo.Abp.Identity.IdentityUser; @@ -71,8 +73,8 @@ namespace Volo.Abp.Account.Web.Pages.Account }) .ToList(); - EnableLocalLogin = true; //TODO: We can get default from a setting? - + EnableLocalLogin = await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin); + ExternalProviders = providers.ToArray(); if (IsExternalLoginOnly) @@ -87,7 +89,7 @@ namespace Volo.Abp.Account.Web.Pages.Account [UnitOfWork] //TODO: Will be removed when we implement action filter public virtual async Task OnPostAsync(string action) { - EnableLocalLogin = true; //TODO: We can get default from a setting? + EnableLocalLogin = await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin); ValidateModel(); diff --git a/modules/account/src/Volo.Abp.Account.Web/Settings/AccountSettingDefinitionProvider.cs b/modules/account/src/Volo.Abp.Account.Web/Settings/AccountSettingDefinitionProvider.cs index 8d3ccba7c9..be16fa7045 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Settings/AccountSettingDefinitionProvider.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Settings/AccountSettingDefinitionProvider.cs @@ -9,6 +9,10 @@ namespace Volo.Abp.Account.Web.Settings context.Add( new SettingDefinition(AccountSettingNames.IsSelfRegistrationEnabled, "true") ); + + context.Add( + new SettingDefinition(AccountSettingNames.EnableLocalLogin, "true") + ); } } } \ No newline at end of file diff --git a/modules/account/src/Volo.Abp.Account.Web/Settings/AccountSettingNames.cs b/modules/account/src/Volo.Abp.Account.Web/Settings/AccountSettingNames.cs index 3122dbdc6a..a167be0ce8 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Settings/AccountSettingNames.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Settings/AccountSettingNames.cs @@ -3,5 +3,7 @@ public class AccountSettingNames { public const string IsSelfRegistrationEnabled = "Abp.Account.IsSelfRegistrationEnabled"; + + public const string EnableLocalLogin = "Abp.Account.EnableLocalLogin"; } }