mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-30 11:43:39 +01:00
performance improvements for queries
This commit is contained in:
parent
b9ac535836
commit
0e0a75a71b
3 changed files with 17 additions and 16 deletions
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue