diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Pages/Account/TwoFactorSupportedLoginModel.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerLoginModel.cs similarity index 85% rename from aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Pages/Account/TwoFactorSupportedLoginModel.cs rename to aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerLoginModel.cs index a10306ef5..dbca7e51a 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Pages/Account/TwoFactorSupportedLoginModel.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerLoginModel.cs @@ -2,11 +2,12 @@ using IdentityServer4.Models; using IdentityServer4.Services; using IdentityServer4.Stores; +using LINGYUN.Abp.Account.Web.ExternalProviders; +using LINGYUN.Abp.Account.Web.Models; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using System; -using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; @@ -18,6 +19,7 @@ using Volo.Abp.Identity; using Volo.Abp.IdentityServer.AspNetIdentity; using Volo.Abp.MultiTenancy; using Volo.Abp.Settings; +using static Volo.Abp.Account.Web.Pages.Account.LoginModel; using IdentityOptions = Microsoft.AspNetCore.Identity.IdentityOptions; namespace LINGYUN.Abp.Account.Web.IdentityServer.Pages.Account @@ -29,12 +31,13 @@ namespace LINGYUN.Abp.Account.Web.IdentityServer.Pages.Account [ExposeServices( typeof(LINGYUN.Abp.Account.Web.Pages.Account.LoginModel), typeof(IdentityServerSupportedLoginModel))] - public class TwoFactorSupportedLoginModel : LINGYUN.Abp.Account.Web.Pages.Account.LoginModel + public class IdentityServerLoginModel : LINGYUN.Abp.Account.Web.Pages.Account.LoginModel { protected IIdentityServerInteractionService Interaction { get; } protected IEventService IdentityServerEvents { get; } protected IClientStore ClientStore { get; } - public TwoFactorSupportedLoginModel( + public IdentityServerLoginModel( + IExternalProviderService externalProviderService, IAuthenticationSchemeProvider schemeProvider, IOptions accountOptions, IOptions identityOptions, @@ -42,7 +45,7 @@ namespace LINGYUN.Abp.Account.Web.IdentityServer.Pages.Account IIdentityServerInteractionService interaction, IEventService identityServerEvents, IClientStore clientStore) - : base(schemeProvider, accountOptions, identityOptions, identityDynamicClaimsPrincipalContributorCache) + : base(externalProviderService, schemeProvider, accountOptions, identityOptions, identityDynamicClaimsPrincipalContributorCache) { Interaction = interaction; ClientStore = clientStore; @@ -74,7 +77,7 @@ namespace LINGYUN.Abp.Account.Web.IdentityServer.Pages.Account if (context?.IdP != null) { LoginInput.UserNameOrEmailAddress = context.LoginHint; - ExternalProviders = new[] { new ExternalProviderModel { AuthenticationScheme = context.IdP } }; + ExternalProviders = new[] { new ExternalLoginProviderModel { AuthenticationScheme = context.IdP } }; return Page(); } @@ -182,26 +185,5 @@ namespace LINGYUN.Abp.Account.Web.IdentityServer.Pages.Account return await RedirectSafelyAsync(ReturnUrl, ReturnUrlHash); } - - protected async override Task> GetExternalProviders() - { - var providers = await base.GetExternalProviders(); - - foreach (var provider in providers) - { - var localizedDisplayName = L[provider.DisplayName]; - if (localizedDisplayName.ResourceNotFound) - { - localizedDisplayName = L["AuthenticationScheme:" + provider.DisplayName]; - } - - if (!localizedDisplayName.ResourceNotFound) - { - provider.DisplayName = localizedDisplayName.Value; - } - } - - return providers; - } } } diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Pages/Account/TwoFactorSupportedLoginModel.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Pages/Account/OpenIddictLoginModel.cs similarity index 79% rename from aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Pages/Account/TwoFactorSupportedLoginModel.cs rename to aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Pages/Account/OpenIddictLoginModel.cs index 41ae2c17e..96bcaed97 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Pages/Account/TwoFactorSupportedLoginModel.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Pages/Account/OpenIddictLoginModel.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Authentication; +using LINGYUN.Abp.Account.Web.ExternalProviders; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using System; @@ -8,6 +9,7 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.Identity; using Volo.Abp.MultiTenancy; using Volo.Abp.OpenIddict; +using static Volo.Abp.Account.Web.Pages.Account.LoginModel; using IdentityOptions = Microsoft.AspNetCore.Identity.IdentityOptions; namespace LINGYUN.Abp.Account.Web.OpenIddict.Pages.Account @@ -15,17 +17,18 @@ namespace LINGYUN.Abp.Account.Web.OpenIddict.Pages.Account [Dependency(ReplaceServices = true)] [ExposeServices( typeof(LINGYUN.Abp.Account.Web.Pages.Account.LoginModel), - typeof(TwoFactorSupportedLoginModel))] - public class TwoFactorSupportedLoginModel : LINGYUN.Abp.Account.Web.Pages.Account.LoginModel + typeof(OpenIddictLoginModel))] + public class OpenIddictLoginModel : LINGYUN.Abp.Account.Web.Pages.Account.LoginModel { protected AbpOpenIddictRequestHelper OpenIddictRequestHelper { get; } - public TwoFactorSupportedLoginModel( + public OpenIddictLoginModel( + IExternalProviderService externalProviderService, IAuthenticationSchemeProvider schemeProvider, IOptions accountOptions, IOptions identityOptions, IdentityDynamicClaimsPrincipalContributorCache identityDynamicClaimsPrincipalContributorCache, AbpOpenIddictRequestHelper openIddictRequestHelper) - : base(schemeProvider, accountOptions, identityOptions, identityDynamicClaimsPrincipalContributorCache) + : base(externalProviderService, schemeProvider, accountOptions, identityOptions, identityDynamicClaimsPrincipalContributorCache) { OpenIddictRequestHelper = openIddictRequestHelper; }