diff --git a/src/Money.UI.Blazor/Services/Navigator.cs b/src/Money.UI.Blazor/Services/Navigator.cs index 795ce72b..55871cca 100644 --- a/src/Money.UI.Blazor/Services/Navigator.cs +++ b/src/Money.UI.Blazor/Services/Navigator.cs @@ -72,15 +72,20 @@ public void OpenUserPassword() public void OpenLogin() { string loginUrl = UrlAccountLogin(); + string currentUrl = GetCurrentUrl(); + + if (loginUrl != currentUrl && currentUrl != UrlAccountRegister()) + uri.NavigateTo($"{loginUrl}?returnUrl={currentUrl}"); + } + + private string GetCurrentUrl() + { string currentUrl = "/" + uri.ToBaseRelativePath(uri.GetBaseUri(), uri.GetAbsoluteUri()); int indexOfReturnUrl = currentUrl.IndexOf("?returnUrl"); if (indexOfReturnUrl >= 0) currentUrl = currentUrl.Substring(0, indexOfReturnUrl); - if (loginUrl != currentUrl) - { - uri.NavigateTo($"{loginUrl}?returnUrl={currentUrl}"); - } + return currentUrl; } public void OpenRegister()