Add createWithIdent fallback

This commit is contained in:
Loporrit
2025-06-28 15:28:06 +00:00
parent 3f45f1865b
commit deffdf35a6

View File

@@ -76,6 +76,24 @@ public sealed class TokenProvider : IDisposable, IMediatorSubscriber
new KeyValuePair<string, string>("charaIdent", await _dalamudUtil.GetPlayerNameHashedAsync().ConfigureAwait(false)), new KeyValuePair<string, string>("charaIdent", await _dalamudUtil.GetPlayerNameHashedAsync().ConfigureAwait(false)),
}), token).ConfigureAwait(false); }), token).ConfigureAwait(false);
if (!result.IsSuccessStatusCode)
{
tokenUri = MareAuth.AuthFullPath(new Uri(_serverManager.CurrentApiUrl
.Replace("wss://", "https://", StringComparison.OrdinalIgnoreCase)
.Replace("ws://", "http://", StringComparison.OrdinalIgnoreCase)));
result = await _httpClient.PostAsync(tokenUri, new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("auth", auth),
new KeyValuePair<string, string>("charaIdent", await _dalamudUtil.GetPlayerNameHashedAsync().ConfigureAwait(false)),
}), token).ConfigureAwait(false);
var textResponse = await result.Content.ReadAsStringAsync().ConfigureAwait(false) ?? string.Empty;
result.EnsureSuccessStatusCode();
_tokenCache[identifier] = textResponse;
_wellKnownCache[_serverManager.CurrentApiUrl] = null;
return textResponse;
}
var response = await result.Content.ReadFromJsonAsync<AuthReplyDto>().ConfigureAwait(false) ?? new(); var response = await result.Content.ReadFromJsonAsync<AuthReplyDto>().ConfigureAwait(false) ?? new();
result.EnsureSuccessStatusCode(); result.EnsureSuccessStatusCode();
_tokenCache[identifier] = response.Token; _tokenCache[identifier] = response.Token;