Skip to content

Commit

Permalink
#115 - Update navigator to include login method.
Browse files Browse the repository at this point in the history
  • Loading branch information
maraf committed Apr 2, 2020
1 parent f5b9861 commit 8795331
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -100,7 +100,7 @@ private async Task<bool> LoadUserInfoAsync()
return true;
}

private void NavigateToLogin() => Uri.NavigateTo("/login");
private void NavigateToLogin() => Navigator.OpenLogin();

public async Task<bool> LoginAsync(string username, string password, bool isPersistent = false)
{
Expand All @@ -110,7 +110,7 @@ public async Task<bool> LoginAsync(string username, string password, bool isPers
SetAuthorization(response.BearerToken, isPersistent);
await LoadUserInfoAsync();

Uri.NavigateTo("/");
Navigator.OpenTimeline();

return true;
}
Expand All @@ -121,7 +121,7 @@ public async Task<bool> LoginAsync(string username, string password, bool isPers
public Task LogoutAsync()
{
ClearAuthorization();
Uri.NavigateTo("/login");
Navigator.OpenLogin();
return Task.FromResult(true);
}

Expand Down
6 changes: 6 additions & 0 deletions src/Recollections.Blazor.UI/Navigator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ public ValueTask<bool> AskAsync(string message)
public ValueTask<bool> MessageAsync(string message)
=> jsRuntime.InvokeAsync<bool>("window.alert", message);

public string UrlLogin()
=> "/login";

public void OpenLogin()
=> uri.NavigateTo(UrlLogin());

public string UrlRegister()
=> "/register";

Expand Down

0 comments on commit 8795331

Please sign in to comment.