From 854dedead3a3ed987997a0132f527db73b65b0ac Mon Sep 17 00:00:00 2001 From: ivar Date: Sat, 11 Nov 2023 22:10:42 +0100 Subject: Div more changes --- .../src/Utilities/BasicAuthenticationHandler.cs | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'code/api/src/Utilities/BasicAuthenticationHandler.cs') diff --git a/code/api/src/Utilities/BasicAuthenticationHandler.cs b/code/api/src/Utilities/BasicAuthenticationHandler.cs index 3b92293..41486ef 100644 --- a/code/api/src/Utilities/BasicAuthenticationHandler.cs +++ b/code/api/src/Utilities/BasicAuthenticationHandler.cs @@ -1,7 +1,6 @@ using System.Net.Http.Headers; using System.Text; using System.Text.Encodings.Web; -using IOL.GreatOffice.Api.Models.Database; using Microsoft.Extensions.Options; namespace IOL.GreatOffice.Api.Utilities; @@ -16,17 +15,18 @@ public class BasicAuthenticationHandler : AuthenticationHandler options, ILoggerFactory logger, UrlEncoder encoder, - ISystemClock clock, MainAppDatabase context, VaultService vaultService ) : - base(options, logger, encoder, clock) { + base(options, logger, encoder) + { _context = context; _configuration = vaultService.GetCurrentAppConfiguration(); _logger = logger.CreateLogger(); } - protected override Task HandleAuthenticateAsync() { + protected override Task HandleAuthenticateAsync() + { var endpoint = Context.GetEndpoint(); if (endpoint?.Metadata.GetMetadata() != null) return Task.FromResult(AuthenticateResult.NoResult()); @@ -34,9 +34,11 @@ public class BasicAuthenticationHandler : AuthenticationHandler c.User).SingleOrDefault(c => c.Id == tokenId); - if (token == default) { + if (token == default) + { return Task.FromResult(AuthenticateResult.Fail("Invalid Authorization Header: Not Found")); } - if (token.HasExpired) { + if (token.HasExpired) + { return Task.FromResult(AuthenticateResult.Fail("Invalid Authorization Header: Expired")); } @@ -72,7 +77,9 @@ public class BasicAuthenticationHandler : AuthenticationHandler