allow connection when characteridentification is not null but it's the same user

This commit is contained in:
Stanley Dimant
2022-07-28 14:10:40 +02:00
parent a44c3c812f
commit 8f391c6afb
2 changed files with 7 additions and 6 deletions

View File

@@ -45,7 +45,7 @@ namespace MareSynchronosServer.Hubs
{
_logger.LogInformation("Connection from " + userId);
var user = (await _dbContext.Users.SingleAsync(u => u.UID == userId));
if (!string.IsNullOrEmpty(user.CharacterIdentification))
if (!string.IsNullOrEmpty(user.CharacterIdentification) && characterIdentification != user.CharacterIdentification)
{
return new ConnectionDto()
{
@@ -86,6 +86,8 @@ namespace MareSynchronosServer.Hubs
public override async Task OnDisconnectedAsync(Exception exception)
{
MareMetrics.Connections.Dec();
var user = await _dbContext.Users.AsNoTracking().SingleOrDefaultAsync(u => u.UID == AuthenticatedUserId);
if (user != null && !string.IsNullOrEmpty(user.CharacterIdentification))
{
@@ -112,8 +114,6 @@ namespace MareSynchronosServer.Hubs
await _dbContext.Users.CountAsync(u => !string.IsNullOrEmpty(u.CharacterIdentification)));
}
MareMetrics.Connections.Dec();
await base.OnDisconnectedAsync(exception);
}