From d9ebbd68ac8e1a6ddc268efe1daeb1c1f9c09e04 Mon Sep 17 00:00:00 2001 From: colin Date: Wed, 17 Jun 2026 13:42:38 +0800 Subject: [PATCH] fix: Fix the link for logging in with the current account --- .../Pages/Account/Login.cshtml | 2 +- .../Pages/Account/Login.cshtml.cs | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/Login.cshtml b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/Login.cshtml index dac94f917..a44496f59 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/Login.cshtml +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/Login.cshtml @@ -27,7 +27,7 @@ @if (Model.IsLinkLogin) { - @L["LinkAccountWarning", Url.PageLink()] + @L["LinkAccountWarning", await Model.GetWithoutLinkReturnUrlAsync(Model.ReturnUrl, Model.ReturnUrlHash)] } diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/Login.cshtml.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/Login.cshtml.cs index 4f338a9d0..8ab17a456 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/Login.cshtml.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/Login.cshtml.cs @@ -19,6 +19,7 @@ using System.ComponentModel.DataAnnotations; using System.Diagnostics; using System.Linq; using System.Security.Claims; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Account.Settings; @@ -668,7 +669,21 @@ public class LoginModel : AccountPageModel #region LinkUser - protected virtual async Task VerifyLinkTokenAsync() + public async virtual Task GetWithoutLinkReturnUrlAsync(string returnUrl, string returnUrlHash) + { + var redirectUrl = await base.GetRedirectUrlAsync(returnUrl, returnUrlHash); + + // 使用正则表达式移除 LinkUser 参数 + redirectUrl = Regex.Replace(redirectUrl, @"[&?]LinkToken=[^&]*", ""); + redirectUrl = Regex.Replace(redirectUrl, @"[&?]LinkUserId=[^&]*", ""); + redirectUrl = Regex.Replace(redirectUrl, @"[&?]LinkTenantId=[^&]*", ""); + redirectUrl = Regex.Replace(redirectUrl, @"[&?]linkUserId=[^&]*", ""); + redirectUrl = Regex.Replace(redirectUrl, @"[&?]linkToken=[^&]*", ""); + + return redirectUrl; + } + + protected async virtual Task VerifyLinkTokenAsync() { if (LinkToken.IsNullOrWhiteSpace() || !LinkUserId.HasValue) {