fixing jwt refresh, index link straight to dashboard
This commit is contained in:
parent
f449c7df82
commit
51c6f0d335
@ -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 partial class App : Application
|
||||||
{
|
{
|
||||||
public App()
|
private readonly NowHubClient nowClient;
|
||||||
|
private readonly ILogger<App> logger;
|
||||||
|
|
||||||
|
public App(NowHubClient nowClient, ILogger<App> logger)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
MainPage = new MainPage();
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
using Selector.SignalR;
|
using Selector.SignalR;
|
||||||
|
|
||||||
@ -33,7 +34,8 @@ public class SelectorNetClient : ISelectorNetClient
|
|||||||
// _baseUrl = "https://selector.sarsoo.xyz";
|
// _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)
|
public async Task<TokenResponse> GetToken(string username, string password)
|
||||||
@ -54,7 +56,10 @@ public class SelectorNetClient : ISelectorNetClient
|
|||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNullOrEmpty(currentKey);
|
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);
|
return FormTokenResponse(result);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
|
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
|
||||||
<nav class="flex-column menu-items">
|
<nav class="flex-column menu-items">
|
||||||
<div class="nav-item px-3">
|
<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
|
<span class="oi oi-home" aria-hidden="true"></span> Home
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</div>
|
</div>
|
||||||
|
@ -9,4 +9,6 @@
|
|||||||
@using Selector.MAUI
|
@using Selector.MAUI
|
||||||
@using Selector.MAUI.Shared
|
@using Selector.MAUI.Shared
|
||||||
@using Selector.MAUI.Models
|
@using Selector.MAUI.Models
|
||||||
@using Selector.MAUI.Services;
|
@using Selector.MAUI.Services
|
||||||
|
@using Radzen
|
||||||
|
@using Radzen.Blazor
|
@ -22,7 +22,8 @@ public abstract class BaseSignalRClient: IAsyncDisposable
|
|||||||
// _baseUrl = "https://selector.sarsoo.xyz";
|
// _baseUrl = "https://selector.sarsoo.xyz";
|
||||||
//}
|
//}
|
||||||
|
|
||||||
_baseUrl = "http://localhost:5000";
|
//_baseUrl = "http://localhost:5000";
|
||||||
|
_baseUrl = "https://selector.sarsoo.xyz";
|
||||||
|
|
||||||
hubConnection = new HubConnectionBuilder()
|
hubConnection = new HubConnectionBuilder()
|
||||||
.WithUrl(_baseUrl + "/" + path, options =>
|
.WithUrl(_baseUrl + "/" + path, options =>
|
||||||
|
Loading…
Reference in New Issue
Block a user