mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 22:17:22 +01:00
fix jwt tokens being stored globally instead of per server
This commit is contained in:
parent
e2931c73ed
commit
b1f02b1483
2 changed files with 5 additions and 5 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Authors></Authors>
|
<Authors></Authors>
|
||||||
<Company></Company>
|
<Company></Company>
|
||||||
<Version>0.5.19</Version>
|
<Version>0.5.20</Version>
|
||||||
<Description></Description>
|
<Description></Description>
|
||||||
<Copyright></Copyright>
|
<Copyright></Copyright>
|
||||||
<PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl>
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ public partial class ApiController : IDisposable, IMareHubClient
|
||||||
private readonly DalamudUtil _dalamudUtil;
|
private readonly DalamudUtil _dalamudUtil;
|
||||||
private readonly FileCacheManager _fileDbManager;
|
private readonly FileCacheManager _fileDbManager;
|
||||||
private CancellationTokenSource _connectionCancellationTokenSource;
|
private CancellationTokenSource _connectionCancellationTokenSource;
|
||||||
private string _jwtToken = string.Empty;
|
private Dictionary<string, string> _jwtToken = new(StringComparer.Ordinal);
|
||||||
private KeyValuePair<string, string> AuthorizationJwtHeader => new("Authorization", "Bearer " + _jwtToken);
|
private KeyValuePair<string, string> AuthorizationJwtHeader => new("Authorization", "Bearer " + _jwtToken[ApiUri]);
|
||||||
|
|
||||||
private HubConnection? _mareHub;
|
private HubConnection? _mareHub;
|
||||||
|
|
||||||
|
|
@ -173,7 +173,7 @@ public partial class ApiController : IDisposable, IMareHubClient
|
||||||
{
|
{
|
||||||
Logger.Debug("Building connection");
|
Logger.Debug("Building connection");
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(_jwtToken) || forceGetToken)
|
if (!_jwtToken.TryGetValue(ApiUri, out var jwtToken) || forceGetToken)
|
||||||
{
|
{
|
||||||
Logger.Debug("Requesting new JWT token");
|
Logger.Debug("Requesting new JWT token");
|
||||||
using HttpClient httpClient = new();
|
using HttpClient httpClient = new();
|
||||||
|
|
@ -187,7 +187,7 @@ public partial class ApiController : IDisposable, IMareHubClient
|
||||||
new KeyValuePair<string, string>("auth", auth)
|
new KeyValuePair<string, string>("auth", auth)
|
||||||
})).ConfigureAwait(false);
|
})).ConfigureAwait(false);
|
||||||
result.EnsureSuccessStatusCode();
|
result.EnsureSuccessStatusCode();
|
||||||
_jwtToken = await result.Content.ReadAsStringAsync().ConfigureAwait(false);
|
_jwtToken[ApiUri] = await result.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||||
Logger.Debug("JWT Token Success");
|
Logger.Debug("JWT Token Success");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue