Browse Source

fix: Fix the issue where login fails when the returnUrl is empty.

pull/1567/head
colin 4 weeks ago
parent
commit
078ecab666
  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]
[BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!;
public string? ReturnUrl { get; set; }
[HiddenInput]
[BindProperty(SupportsGet = true)]
@ -135,7 +135,7 @@ public class ChangePasswordModel : AccountPageModel
UserName = user.UserName
});
await IdentityDynamicClaimsPrincipalContributorCache.ClearAsync(user.Id, user.TenantId);
return await RedirectSafelyAsync(ReturnUrl, ReturnUrlHash);
return await RedirectSafelyAsync(ReturnUrl!, ReturnUrlHash);
}
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]
[BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!;
public string? ReturnUrl { get; set; }
[HiddenInput]
[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
{
[BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!;
public string? ReturnUrl { get; set; }
[BindProperty(SupportsGet = true)]
public string? ReturnUrlHash { get; set; }
public async virtual Task<IActionResult> OnGetAsync()
{
ReturnUrl = await GetRedirectUrlAsync(ReturnUrl, ReturnUrlHash);
ReturnUrl = await GetRedirectUrlAsync(ReturnUrl!, ReturnUrlHash);
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
{
[BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!;
public string? ReturnUrl { get; set; }
[BindProperty(SupportsGet = true)]
public string? ReturnUrlHash { get; set; }
@ -56,7 +56,7 @@ public class LinkLoggedModel : AccountPageModel
{
if (LinkUserId == CurrentUser.Id && LinkTenantId == CurrentTenant.Id)
{
return await RedirectSafelyAsync(ReturnUrl, ReturnUrlHash);
return await RedirectSafelyAsync(ReturnUrl!, ReturnUrlHash);
}
using (CurrentTenant.Change(LinkTenantId))
@ -81,7 +81,7 @@ public class LinkLoggedModel : AccountPageModel
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();
}
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()

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

@ -41,7 +41,7 @@ public class LoginModel : AccountPageModel
{
[HiddenInput]
[BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!;
public string? ReturnUrl { get; set; }
[HiddenInput]
[BindProperty(SupportsGet = true)]
@ -217,7 +217,7 @@ public class LoginModel : AccountPageModel
// Clear the dynamic claims cache.
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)
@ -269,7 +269,7 @@ public class LoginModel : AccountPageModel
// Clear the dynamic claims cache.
await IdentityDynamicClaimsPrincipalContributorCache.ClearAsync(user.Id, user.TenantId);
return await RedirectSafelyAsync(ReturnUrl, ReturnUrlHash);
return await RedirectSafelyAsync(ReturnUrl!, ReturnUrlHash);
}
protected virtual void SetTenantCookies(Guid? tenantId = null)
@ -356,7 +356,7 @@ public class LoginModel : AccountPageModel
// Clear the dynamic claims cache.
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
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 参数
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]
[BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!;
public string? ReturnUrl { get; set; }
[HiddenInput]
[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]
[BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!;
public string? ReturnUrl { get; set; }
[HiddenInput]
[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]
[BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!;
public string? ReturnUrl { get; set; }
[HiddenInput]
[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]
[BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!;
public string? ReturnUrl { get; set; }
[HiddenInput]
[BindProperty(SupportsGet = true)]
@ -37,7 +37,7 @@ namespace LINGYUN.Abp.Account.Web.Pages.Account
var result = await SignInManager.TwoFactorAuthenticatorSignInAsync(Input.VerifyCode, RememberMe, RememberBrowser);
if (result.Succeeded)
{
return await RedirectSafelyAsync(ReturnUrl, ReturnUrlHash);
return await RedirectSafelyAsync(ReturnUrl!, ReturnUrlHash);
}
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>
[HiddenInput]
[BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; } = default!;
public string? ReturnUrl { get; set; }
/// <summary>
///
/// </summary>
@ -96,7 +96,7 @@ namespace LINGYUN.Abp.Account.Web.Pages.Account
// Clear the dynamic claims cache.
await IdentityDynamicClaimsPrincipalContributorCache.ClearAsync(user.Id, user.TenantId);
return await RedirectSafelyAsync(ReturnUrl, ReturnUrlHash);
return await RedirectSafelyAsync(ReturnUrl!, ReturnUrlHash);
}
if (result.IsLockedOut)
{

Loading…
Cancel
Save