fixing jwt refresh, index link straight to dashboard

This commit is contained in:
Andy Pack 2023-01-27 23:32:12 +00:00
parent f449c7df82
commit 51c6f0d335
Signed by: sarsoo
GPG Key ID: A55BA3536A5E0ED7
5 changed files with 55 additions and 8 deletions

View File

@ -1,12 +1,51 @@
namespace Selector.MAUI;
using Microsoft.AspNetCore.SignalR.Client;
using Microsoft.Extensions.Logging;
using Selector.SignalR;
namespace Selector.MAUI;
public partial class App : Application
{
public App()
private readonly NowHubClient nowClient;
private readonly ILogger<App> logger;
public App(NowHubClient nowClient, ILogger<App> logger)
{
InitializeComponent();
MainPage = new MainPage();
}
this.nowClient = nowClient;
this.logger = logger;
}
protected override Window CreateWindow(IActivationState activationState)
{
Window window = base.CreateWindow(activationState);
window.Resumed += async (s, e) =>
{
try
{
logger.LogInformation("Window resumed, reconnecting hubs");
if (nowClient.State == HubConnectionState.Disconnected)
{
await nowClient.StartAsync();
}
await nowClient.OnConnected();
logger.LogInformation("Hubs reconnected");
}
catch(Exception ex)
{
logger.LogError(ex, "Error while reconnecting hubs");
}
};
return window;
}
}

View File

@ -1,5 +1,6 @@
using System;
using System.Net;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using Selector.SignalR;
@ -33,7 +34,8 @@ public class SelectorNetClient : ISelectorNetClient
// _baseUrl = "https://selector.sarsoo.xyz";
//}
_baseUrl = "http://localhost:5000";
//_baseUrl = "http://localhost:5000";
_baseUrl = "https://selector.sarsoo.xyz";
}
public async Task<TokenResponse> GetToken(string username, string password)
@ -54,7 +56,10 @@ public class SelectorNetClient : ISelectorNetClient
{
ArgumentNullException.ThrowIfNullOrEmpty(currentKey);
var result = await _client.PostAsync(_baseUrl + "/api/auth/token", new StringContent(string.Empty));
var request = new HttpRequestMessage(HttpMethod.Post, _baseUrl + "/api/auth/token");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", currentKey);
var result = await _client.SendAsync(request);
return FormTokenResponse(result);
}

View File

@ -3,7 +3,7 @@
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
<nav class="flex-column menu-items">
<div class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<NavLink class="nav-link" href="app" Match="NavLinkMatch.All">
<span class="oi oi-home" aria-hidden="true"></span> Home
</NavLink>
</div>

View File

@ -9,4 +9,6 @@
@using Selector.MAUI
@using Selector.MAUI.Shared
@using Selector.MAUI.Models
@using Selector.MAUI.Services;
@using Selector.MAUI.Services
@using Radzen
@using Radzen.Blazor

View File

@ -22,7 +22,8 @@ public abstract class BaseSignalRClient: IAsyncDisposable
// _baseUrl = "https://selector.sarsoo.xyz";
//}
_baseUrl = "http://localhost:5000";
//_baseUrl = "http://localhost:5000";
_baseUrl = "https://selector.sarsoo.xyz";
hubConnection = new HubConnectionBuilder()
.WithUrl(_baseUrl + "/" + path, options =>