Skip to content

Commit

Permalink
fix #3827 - Cancel button should redirect to RedirectUrl (using PageS…
Browse files Browse the repository at this point in the history
…tate.ReturnUrl)
  • Loading branch information
sbwalker committed Feb 21, 2024
1 parent 7b38683 commit eac7fcc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
15 changes: 4 additions & 11 deletions Oqtane.Client/Modules/Admin/Login/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@
private bool _alwaysremember = false;
private string _code = string.Empty;

private string _returnUrl = string.Empty;

public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous;

public override List<Resource> Resources => new List<Resource>()
Expand All @@ -108,11 +106,6 @@

_togglepassword = SharedLocalizer["ShowPassword"];

if (PageState.QueryString.ContainsKey("returnurl"))
{
_returnUrl = PageState.QueryString["returnurl"];
}

if (PageState.QueryString.ContainsKey("name"))
{
_username = PageState.QueryString["name"];
Expand Down Expand Up @@ -213,12 +206,12 @@
// hybrid apps utilize an interactive login
var authstateprovider = (IdentityAuthenticationStateProvider)ServiceProvider.GetService(typeof(IdentityAuthenticationStateProvider));
authstateprovider.NotifyAuthenticationChanged();
NavigationManager.NavigateTo(NavigateUrl(WebUtility.UrlDecode(_returnUrl), true));
NavigationManager.NavigateTo(NavigateUrl(PageState.ReturnUrl, true));
}
else
{
// post back to the Login page so that the cookies are set correctly
var fields = new { __RequestVerificationToken = SiteState.AntiForgeryToken, username = _username, password = _password, remember = _remember, returnurl = _returnUrl };
var fields = new { __RequestVerificationToken = SiteState.AntiForgeryToken, username = _username, password = _password, remember = _remember, returnurl = WebUtility.UrlEncode(PageState.ReturnUrl) };
string url = Utilities.TenantUrl(PageState.Alias, "/pages/login/");
await interop.SubmitForm(url, fields);
}
Expand Down Expand Up @@ -260,7 +253,7 @@

private void Cancel()
{
NavigationManager.NavigateTo(WebUtility.UrlDecode(_returnUrl));
NavigationManager.NavigateTo(PageState.ReturnUrl);
}

private async Task Forgot()
Expand Down Expand Up @@ -328,7 +321,7 @@

private void ExternalLogin()
{
NavigationManager.NavigateTo(Utilities.TenantUrl(PageState.Alias, "/pages/external?returnurl=" + _returnUrl), true);
NavigationManager.NavigateTo(Utilities.TenantUrl(PageState.Alias, "/pages/external?returnurl=" + WebUtility.UrlEncode(PageState.ReturnUrl)), true);
}

}
6 changes: 3 additions & 3 deletions Oqtane.Client/Modules/Admin/Register/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ else
if (user != null)
{
await logger.LogInformation("User Created {Username} {Email}", _username, _email);
if (PageState.QueryString.ContainsKey("returnurl"))
if (!string.IsNullOrEmpty(PageState.ReturnUrl))
{
NavigationManager.NavigateTo(WebUtility.UrlDecode(PageState.QueryString["returnurl"]));
NavigationManager.NavigateTo(PageState.ReturnUrl);
}
else // legacy behavior
{
Expand Down Expand Up @@ -167,7 +167,7 @@ else

private void Cancel()
{
NavigationManager.NavigateTo(NavigateUrl(string.Empty));
NavigationManager.NavigateTo(PageState.ReturnUrl);
}

private void TogglePassword()
Expand Down
6 changes: 3 additions & 3 deletions Oqtane.Client/Modules/Admin/UserProfile/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,9 @@
await SettingService.UpdateUserSettingsAsync(settings, PageState.User.UserId);
await logger.LogInformation("User Profile Saved");

if (PageState.QueryString.ContainsKey("returnurl"))
if (!string.IsNullOrEmpty(PageState.ReturnUrl))
{
NavigationManager.NavigateTo(WebUtility.UrlDecode(PageState.QueryString["returnurl"]));
NavigationManager.NavigateTo(PageState.ReturnUrl);
}
else // legacy behavior
{
Expand Down Expand Up @@ -551,7 +551,7 @@

private void Cancel()
{
NavigationManager.NavigateTo(NavigateUrl(string.Empty));
NavigationManager.NavigateTo(PageState.ReturnUrl);
}

private void ProfileChanged(ChangeEventArgs e, string SettingName)
Expand Down

0 comments on commit eac7fcc

Please sign in to comment.