performance improvements for queries

This commit is contained in:
Stanley Dimant 2022-07-11 02:54:03 +02:00
parent b9ac535836
commit 0e0a75a71b
3 changed files with 17 additions and 16 deletions

View file

@ -32,15 +32,15 @@ namespace MareSynchronosServer.Authentication
using var sha256 = SHA256.Create();
var hashedHeader = BitConverter.ToString(sha256.ComputeHash(Encoding.UTF8.GetBytes(authHeader))).Replace("-", "");
var user = await _mareDbContext.Users.AsNoTracking().SingleOrDefaultAsync(m => m.SecretKey == hashedHeader);
var uid = (await _mareDbContext.Users.AsNoTracking().FirstOrDefaultAsync(m => m.SecretKey == hashedHeader))?.UID;
if (user == null)
if (uid == null)
{
return AuthenticateResult.Fail("Failed Authorization");
}
var claims = new List<Claim> {
new Claim(ClaimTypes.NameIdentifier, user.UID)
new Claim(ClaimTypes.NameIdentifier, uid)
};
var identity = new ClaimsIdentity(claims, nameof(SecretKeyAuthenticationHandler));