add multi chracter key checks

This commit is contained in:
Stanley Dimant
2024-07-19 11:45:38 +02:00
committed by Loporrit
parent d9d10c42de
commit 0228c2343b
7 changed files with 35 additions and 16 deletions

View File

@@ -115,7 +115,18 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
return;
}
var secretKey = _serverManager.GetSecretKey();
var secretKey = _serverManager.GetSecretKey(out bool multi);
if (multi)
{
Logger.LogWarning("Multiple secret keys for current character");
_connectionDto = null;
Mediator.Publish(new NotificationMessage("Multiple Identical Characters detected", "Your Service configuration has multiple characters with the same name and world set up. Delete the duplicates in the character management to be able to connect to Mare.",
NotificationType.Error));
await StopConnection(ServerState.MultiChara).ConfigureAwait(false);
_connectionCancellationTokenSource?.Cancel();
return;
}
if (secretKey.IsNullOrEmpty())
{
Logger.LogWarning("No secret key set for current character");

View File

@@ -64,7 +64,7 @@ public sealed class TokenProvider : IDisposable, IMediatorSubscriber
tokenUri = MareAuth.AuthFullPath(new Uri(_serverManager.CurrentApiUrl
.Replace("wss://", "https://", StringComparison.OrdinalIgnoreCase)
.Replace("ws://", "http://", StringComparison.OrdinalIgnoreCase)));
var secretKey = _serverManager.GetSecretKey()!;
var secretKey = _serverManager.GetSecretKey(out _)!;
var auth = secretKey.GetHash256();
result = await _httpClient.PostAsync(tokenUri, new FormUrlEncodedContent(new[]
{
@@ -103,7 +103,7 @@ public sealed class TokenProvider : IDisposable, IMediatorSubscriber
{
jwtIdentifier = new(_serverManager.CurrentApiUrl,
_dalamudUtil.GetPlayerNameHashedAsync().GetAwaiter().GetResult(),
_serverManager.GetSecretKey()!);
_serverManager.GetSecretKey(out _)!);
_lastJwtIdentifier = jwtIdentifier;
}
catch (Exception ex)

View File

@@ -12,4 +12,5 @@ public enum ServerState
VersionMisMatch,
RateLimited,
NoSecretKey,
MultiChara,
}