From 34303cf9d4e074b55c3da743e7e300fc3e8d58df Mon Sep 17 00:00:00 2001 From: colin Date: Sat, 7 Jun 2025 19:15:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(account):=20=E9=87=8D=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E9=87=8D=E5=86=99=E7=9A=84=E7=99=BB=E5=BD=95=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 重命名 `IdentityServer` 登录模型 - 重命名 `OpenIddict` 登录模型 --- ...inModel.cs => IdentityServerLoginModel.cs} | 34 +++++-------------- ...dLoginModel.cs => OpenIddictLoginModel.cs} | 13 ++++--- 2 files changed, 16 insertions(+), 31 deletions(-) rename aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Pages/Account/{TwoFactorSupportedLoginModel.cs => IdentityServerLoginModel.cs} (85%) rename aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Pages/Account/{TwoFactorSupportedLoginModel.cs => OpenIddictLoginModel.cs} (79%) 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; }