Browse Source

Merge pull request #1567 from colinin/fix-return-url-is-null-or-empty

fix: Fix the issue where login fails when the returnUrl is empty.
dev
yx lin 4 weeks ago
committed by GitHub
parent
commit
4309d090a7
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/ChangePassword.cshtml.cs
  2. 2
      aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/EmailConfirm.cshtml.cs
  3. 4
      aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/EmailConfirmConfirmation.cshtml.cs
  4. 10
      aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/LinkLogged.cshtml.cs
  5. 12
      aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/Login.cshtml.cs
  6. 2
      aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/Register.cshtml.cs
  7. 2
      aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/SendCode.cshtml.cs
  8. 2
      aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/SendEmailConfirm.cshtml.cs
  9. 4
      aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/VerifyAuthenticatorCode.cshtml.cs
  10. 4
      aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/VerifyCode.cshtml.cs

4
aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/ChangePassword.cshtml.cs

@ -56,7 +56,7 @@ public class ChangePasswordModel : AccountPageModel
[HiddenInput] [HiddenInput]
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!; public string? ReturnUrl { get; set; }
[HiddenInput] [HiddenInput]
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]
@ -135,7 +135,7 @@ public class ChangePasswordModel : AccountPageModel
UserName = user.UserName UserName = user.UserName
}); });
await IdentityDynamicClaimsPrincipalContributorCache.ClearAsync(user.Id, user.TenantId); await IdentityDynamicClaimsPrincipalContributorCache.ClearAsync(user.Id, user.TenantId);
return await RedirectSafelyAsync(ReturnUrl, ReturnUrlHash); return await RedirectSafelyAsync(ReturnUrl!, ReturnUrlHash);
} }
catch (Exception ex) catch (Exception ex)
{ {

2
aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/EmailConfirm.cshtml.cs

@ -24,7 +24,7 @@ namespace LINGYUN.Abp.Account.Web.Pages.Account
[HiddenInput] [HiddenInput]
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!; public string? ReturnUrl { get; set; }
[HiddenInput] [HiddenInput]
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]

4
aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/EmailConfirmConfirmation.cshtml.cs

@ -9,14 +9,14 @@ namespace LINGYUN.Abp.Account.Web.Pages.Account;
public class EmailConfirmConfirmationModel : AccountPageModel public class EmailConfirmConfirmationModel : AccountPageModel
{ {
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!; public string? ReturnUrl { get; set; }
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]
public string? ReturnUrlHash { get; set; } public string? ReturnUrlHash { get; set; }
public async virtual Task<IActionResult> OnGetAsync() public async virtual Task<IActionResult> OnGetAsync()
{ {
ReturnUrl = await GetRedirectUrlAsync(ReturnUrl, ReturnUrlHash); ReturnUrl = await GetRedirectUrlAsync(ReturnUrl!, ReturnUrlHash);
return Page(); return Page();
} }

10
aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/LinkLogged.cshtml.cs

@ -14,7 +14,7 @@ namespace LINGYUN.Abp.Account.Web.Pages.Account;
public class LinkLoggedModel : AccountPageModel public class LinkLoggedModel : AccountPageModel
{ {
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!; public string? ReturnUrl { get; set; }
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]
public string? ReturnUrlHash { get; set; } public string? ReturnUrlHash { get; set; }
@ -56,7 +56,7 @@ public class LinkLoggedModel : AccountPageModel
{ {
if (LinkUserId == CurrentUser.Id && LinkTenantId == CurrentTenant.Id) if (LinkUserId == CurrentUser.Id && LinkTenantId == CurrentTenant.Id)
{ {
return await RedirectSafelyAsync(ReturnUrl, ReturnUrlHash); return await RedirectSafelyAsync(ReturnUrl!, ReturnUrlHash);
} }
using (CurrentTenant.Change(LinkTenantId)) using (CurrentTenant.Change(LinkTenantId))
@ -81,7 +81,7 @@ public class LinkLoggedModel : AccountPageModel
await IdentityDynamicClaimsPrincipalContributorCache.ClearAsync(targetUser.Id, targetUser.TenantId); await IdentityDynamicClaimsPrincipalContributorCache.ClearAsync(targetUser.Id, targetUser.TenantId);
} }
return await RedirectSafelyAsync(ReturnUrl, ReturnUrlHash); return await RedirectSafelyAsync(ReturnUrl!, ReturnUrlHash);
} }
} }
} }
@ -90,9 +90,9 @@ public class LinkLoggedModel : AccountPageModel
return Page(); return Page();
} }
public virtual Task<string> GetReturnUrlAsync(string returnUrl, string? returnUrlHash = null) public virtual Task<string> GetReturnUrlAsync(string? returnUrl, string? returnUrlHash = null)
{ {
return base.GetRedirectUrlAsync(returnUrl, returnUrlHash); return base.GetRedirectUrlAsync(returnUrl!, returnUrlHash);
} }
protected virtual Task<IActionResult> RedirectToLoginPageAsync() protected virtual Task<IActionResult> RedirectToLoginPageAsync()

12
aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/Login.cshtml.cs

@ -41,7 +41,7 @@ public class LoginModel : AccountPageModel
{ {
[HiddenInput] [HiddenInput]
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!; public string? ReturnUrl { get; set; }
[HiddenInput] [HiddenInput]
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]
@ -217,7 +217,7 @@ public class LoginModel : AccountPageModel
// Clear the dynamic claims cache. // Clear the dynamic claims cache.
await IdentityDynamicClaimsPrincipalContributorCache.ClearAsync(user.Id, user.TenantId); await IdentityDynamicClaimsPrincipalContributorCache.ClearAsync(user.Id, user.TenantId);
return await RedirectSafelyAsync(ReturnUrl, ReturnUrlHash); return await RedirectSafelyAsync(ReturnUrl!, ReturnUrlHash);
} }
public async virtual Task<IActionResult> OnPostPhoneNumberLogin(string action) public async virtual Task<IActionResult> OnPostPhoneNumberLogin(string action)
@ -269,7 +269,7 @@ public class LoginModel : AccountPageModel
// Clear the dynamic claims cache. // Clear the dynamic claims cache.
await IdentityDynamicClaimsPrincipalContributorCache.ClearAsync(user.Id, user.TenantId); await IdentityDynamicClaimsPrincipalContributorCache.ClearAsync(user.Id, user.TenantId);
return await RedirectSafelyAsync(ReturnUrl, ReturnUrlHash); return await RedirectSafelyAsync(ReturnUrl!, ReturnUrlHash);
} }
protected virtual void SetTenantCookies(Guid? tenantId = null) protected virtual void SetTenantCookies(Guid? tenantId = null)
@ -356,7 +356,7 @@ public class LoginModel : AccountPageModel
// Clear the dynamic claims cache. // Clear the dynamic claims cache.
await IdentityDynamicClaimsPrincipalContributorCache.ClearAsync(user.Id, user.TenantId); await IdentityDynamicClaimsPrincipalContributorCache.ClearAsync(user.Id, user.TenantId);
return await RedirectSafelyAsync(ReturnUrl, ReturnUrlHash); return await RedirectSafelyAsync(ReturnUrl!, ReturnUrlHash);
} }
} }
@ -669,9 +669,9 @@ public class LoginModel : AccountPageModel
#region LinkUser #region LinkUser
public async virtual Task<string> GetWithoutLinkReturnUrlAsync(string returnUrl, string? returnUrlHash = null) public async virtual Task<string> GetWithoutLinkReturnUrlAsync(string? returnUrl, string? returnUrlHash = null)
{ {
var redirectUrl = await base.GetRedirectUrlAsync(returnUrl, returnUrlHash); var redirectUrl = await base.GetRedirectUrlAsync(returnUrl!, returnUrlHash);
// 使用正则表达式移除 LinkUser 参数 // 使用正则表达式移除 LinkUser 参数
redirectUrl = Regex.Replace(redirectUrl, @"[&?]LinkToken=[^&]*", ""); redirectUrl = Regex.Replace(redirectUrl, @"[&?]LinkToken=[^&]*", "");

2
aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/Register.cshtml.cs

@ -32,7 +32,7 @@ public class RegisterModel : AccountPageModel
{ {
[HiddenInput] [HiddenInput]
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!; public string? ReturnUrl { get; set; }
[HiddenInput] [HiddenInput]
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]

2
aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/SendCode.cshtml.cs

@ -20,7 +20,7 @@ namespace LINGYUN.Abp.Account.Web.Pages.Account
[HiddenInput] [HiddenInput]
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!; public string? ReturnUrl { get; set; }
[HiddenInput] [HiddenInput]
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]

2
aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/SendEmailConfirm.cshtml.cs

@ -14,7 +14,7 @@ namespace LINGYUN.Abp.Account.Web.Pages.Account
[HiddenInput] [HiddenInput]
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!; public string? ReturnUrl { get; set; }
[HiddenInput] [HiddenInput]
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]

4
aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/VerifyAuthenticatorCode.cshtml.cs

@ -13,7 +13,7 @@ namespace LINGYUN.Abp.Account.Web.Pages.Account
[HiddenInput] [HiddenInput]
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!; public string? ReturnUrl { get; set; }
[HiddenInput] [HiddenInput]
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]
@ -37,7 +37,7 @@ namespace LINGYUN.Abp.Account.Web.Pages.Account
var result = await SignInManager.TwoFactorAuthenticatorSignInAsync(Input.VerifyCode, RememberMe, RememberBrowser); var result = await SignInManager.TwoFactorAuthenticatorSignInAsync(Input.VerifyCode, RememberMe, RememberBrowser);
if (result.Succeeded) if (result.Succeeded)
{ {
return await RedirectSafelyAsync(ReturnUrl, ReturnUrlHash); return await RedirectSafelyAsync(ReturnUrl!, ReturnUrlHash);
} }
if (result.IsLockedOut) if (result.IsLockedOut)
{ {

4
aspnet-core/modules/account/LINGYUN.Abp.Account.Web/Pages/Account/VerifyCode.cshtml.cs

@ -28,7 +28,7 @@ namespace LINGYUN.Abp.Account.Web.Pages.Account
/// </summary> /// </summary>
[HiddenInput] [HiddenInput]
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!; public string? ReturnUrl { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@ -96,7 +96,7 @@ namespace LINGYUN.Abp.Account.Web.Pages.Account
// Clear the dynamic claims cache. // Clear the dynamic claims cache.
await IdentityDynamicClaimsPrincipalContributorCache.ClearAsync(user.Id, user.TenantId); await IdentityDynamicClaimsPrincipalContributorCache.ClearAsync(user.Id, user.TenantId);
return await RedirectSafelyAsync(ReturnUrl, ReturnUrlHash); return await RedirectSafelyAsync(ReturnUrl!, ReturnUrlHash);
} }
if (result.IsLockedOut) if (result.IsLockedOut)
{ {

Loading…
Cancel
Save