add LastLoggedIn migration, disallow secondary connections

This commit is contained in:
Stanley Dimant
2022-07-18 10:34:11 +02:00
parent 130350b71b
commit f8ecd3965d
8 changed files with 249 additions and 14 deletions

View File

@@ -43,9 +43,18 @@ namespace MareSynchronosServer.Hubs
if (userId != null && !isBanned && !string.IsNullOrEmpty(characterIdentification))
{
MareMetrics.AuthorizedConnections.Inc();
_logger.LogInformation("Connection from " + userId);
var user = (await _dbContext.Users.SingleAsync(u => u.UID == userId));
if (!string.IsNullOrEmpty(user.CharacterIdentification))
{
return new ConnectionDto()
{
ServerVersion = Api.Version
};
}
MareMetrics.AuthorizedConnections.Inc();
user.LastLoggedIn = DateTime.UtcNow;
user.CharacterIdentification = characterIdentification;
await _dbContext.SaveChangesAsync();
return new ConnectionDto