diff --git a/src/Recollections.Blazor.UI/Accounts/Components/UserState.razor.cs b/src/Recollections.Blazor.UI/Accounts/Components/UserState.razor.cs index 9c552150..ed1b24d1 100644 --- a/src/Recollections.Blazor.UI/Accounts/Components/UserState.razor.cs +++ b/src/Recollections.Blazor.UI/Accounts/Components/UserState.razor.cs @@ -19,7 +19,7 @@ public partial class UserState protected Api Api { get; set; } [Inject] - protected NavigationManager Uri { get; set; } + protected Navigator Navigator { get; set; } [Inject] protected Interop Interop { get; set; } @@ -100,7 +100,7 @@ private async Task LoadUserInfoAsync() return true; } - private void NavigateToLogin() => Uri.NavigateTo("/login"); + private void NavigateToLogin() => Navigator.OpenLogin(); public async Task LoginAsync(string username, string password, bool isPersistent = false) { @@ -110,7 +110,7 @@ public async Task LoginAsync(string username, string password, bool isPers SetAuthorization(response.BearerToken, isPersistent); await LoadUserInfoAsync(); - Uri.NavigateTo("/"); + Navigator.OpenTimeline(); return true; } @@ -121,7 +121,7 @@ public async Task LoginAsync(string username, string password, bool isPers public Task LogoutAsync() { ClearAuthorization(); - Uri.NavigateTo("/login"); + Navigator.OpenLogin(); return Task.FromResult(true); } diff --git a/src/Recollections.Blazor.UI/Navigator.cs b/src/Recollections.Blazor.UI/Navigator.cs index 14a7c56a..35c12970 100644 --- a/src/Recollections.Blazor.UI/Navigator.cs +++ b/src/Recollections.Blazor.UI/Navigator.cs @@ -44,6 +44,12 @@ public ValueTask AskAsync(string message) public ValueTask MessageAsync(string message) => jsRuntime.InvokeAsync("window.alert", message); + public string UrlLogin() + => "/login"; + + public void OpenLogin() + => uri.NavigateTo(UrlLogin()); + public string UrlRegister() => "/register";