diff --git a/Components/RequiresAuth.razor b/Components/RequiresAuth.razor
index db35088..ab959d7 100644
--- a/Components/RequiresAuth.razor
+++ b/Components/RequiresAuth.razor
@@ -3,20 +3,8 @@
@inject APIService api
@inject NavigationManager Navigation
-@if (IsReady) {
- @if (IsAuthenticated) {
- @ChildContent
- } else {
-
-
- Blazing Console
-
-
- Log in first
- Log in
-
-
- }
+@if (IsAuthenticated) {
+ @ChildContent
} else {
@if (LoadingContent != null) {
@LoadingContent
@@ -25,29 +13,24 @@
}
}
-
-
@code {
- public bool IsReady { get; set; } = false;
public bool IsAuthenticated { get; set; } = false;
protected override async Task OnInitializedAsync()
{
string? jwt = await localStorage.GetItemAsync("jwt");
if (jwt == null) {
- IsAuthenticated = false;
- IsReady = true;
+ Navigation.NavigateTo("/login", false);
return;
}
api.SetJwt(jwt);
bool authorized = await api.TestAuthorization();
- IsAuthenticated = authorized;
- IsReady = true;
- }
-
- public void LoginButtonClicked() {
- Navigation.NavigateTo("/login", false);
+ if (authorized) {
+ IsAuthenticated = true;
+ } else {
+ Navigation.NavigateTo("/login", false);
+ }
}
[Parameter]