mirror of
https://github.com/Caraxi/mare.server.git
synced 2026-02-21 23:07:42 +01:00
add logging stuff
This commit is contained in:
parent
d56923d553
commit
15b220dc8b
9 changed files with 81 additions and 49 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
|
|
@ -16,6 +17,7 @@ namespace MareSynchronosServer.Authentication
|
|||
{
|
||||
public class SecretKeyAuthenticationHandler : AuthenticationHandler<AuthenticationSchemeOptions>
|
||||
{
|
||||
public static ConcurrentDictionary<string, object> IdentificationLocks = new();
|
||||
private readonly MareDbContext _mareDbContext;
|
||||
public const string AuthScheme = "SecretKeyAuth";
|
||||
|
||||
|
|
@ -45,15 +47,26 @@ namespace MareSynchronosServer.Authentication
|
|||
return AuthenticateResult.Fail("Failed Authorization");
|
||||
}
|
||||
|
||||
if (!IdentificationLocks.TryGetValue(charNameHeader, out var lockObject))
|
||||
{
|
||||
lockObject = new();
|
||||
IdentificationLocks[charNameHeader] = lockObject;
|
||||
}
|
||||
|
||||
if (user.CharacterIdentification != charNameHeader)
|
||||
{
|
||||
try
|
||||
lock (lockObject)
|
||||
{
|
||||
user.CharacterIdentification = charNameHeader;
|
||||
_mareDbContext.Users.Update(user);
|
||||
await _mareDbContext.SaveChangesAsync();
|
||||
try
|
||||
{
|
||||
user.CharacterIdentification = charNameHeader;
|
||||
_mareDbContext.Users.Update(user);
|
||||
_mareDbContext.SaveChanges();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
}
|
||||
}
|
||||
catch (DbUpdateConcurrencyException) { }
|
||||
}
|
||||
|
||||
var claims = new List<Claim> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue