maybe fix getting key shit

This commit is contained in:
Stanley Dimant
2025-02-06 10:46:07 +01:00
parent 9af89200c8
commit 4d5cc5d9b1
2 changed files with 12 additions and 7 deletions

View File

@@ -104,24 +104,24 @@ public class ServerConfigurationManager
var auth = currentServer.Authentications.FindAll(f => string.Equals(f.CharacterName, charaName) && f.WorldId == worldId);
if (auth.Count >= 2)
{
_logger.LogTrace("GetSecretKey accessed, returning null because multiple ({count}) identical characters.", auth.Count);
_logger.LogTrace("GetOAuth2 accessed, returning null because multiple ({count}) identical characters.", auth.Count);
hasMulti = true;
return null;
}
if (auth.Count == 0)
{
_logger.LogTrace("GetSecretKey accessed, returning null because no set up characters for {chara} on {world}", charaName, worldId);
_logger.LogTrace("GetOAuth2 accessed, returning null because no set up characters for {chara} on {world}", charaName, worldId);
return null;
}
if (!string.IsNullOrEmpty(auth.Single().UID) && !string.IsNullOrEmpty(currentServer.OAuthToken))
{
_logger.LogTrace("GetSecretKey accessed, returning {key} ({keyValue}) for {chara} on {world}", auth.Single().UID, string.Join("", currentServer.OAuthToken.Take(10)), charaName, worldId);
_logger.LogTrace("GetOAuth2 accessed, returning {key} ({keyValue}) for {chara} on {world}", auth.Single().UID, string.Join("", currentServer.OAuthToken.Take(10)), charaName, worldId);
return (currentServer.OAuthToken, auth.Single().UID!);
}
_logger.LogTrace("GetSecretKey accessed, returning null because no UID found for {chara} on {world} or OAuthToken is not configured.", charaName, worldId);
_logger.LogTrace("GetOAuth2 accessed, returning null because no UID found for {chara} on {world} or OAuthToken is not configured.", charaName, worldId);
return null;
}

View File

@@ -162,17 +162,22 @@ public sealed class TokenProvider : IDisposable, IMediatorSubscriber
if (_serverManager.CurrentServer.UseOAuth2)
{
var oauthInfo = _serverManager.GetOAuth2(out _)!;
var (OAuthToken, UID) = _serverManager.GetOAuth2(out _)
?? throw new InvalidOperationException("Requested OAuth2 but received null");
jwtIdentifier = new(_serverManager.CurrentApiUrl,
playerIdentifier,
oauthInfo.Value.UID, oauthInfo.Value.OAuthToken);
UID, OAuthToken);
}
else
{
var secretKey = _serverManager.GetSecretKey(out _)
?? throw new InvalidOperationException("Requested SecretKey but received null");
jwtIdentifier = new(_serverManager.CurrentApiUrl,
playerIdentifier,
string.Empty,
_serverManager.GetSecretKey(out _)!);
secretKey);
}
_lastJwtIdentifier = jwtIdentifier;
}