From 00f6521f8818761c9395cd32122f588e6c4aa260 Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Thu, 26 Dec 2024 18:51:29 +0200 Subject: [PATCH] Fixes previous authoriation permissions not being cleared when a new user logs in --- .../Common/Services/CachedAuthorizationHandler.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Lumina.Presentation.Web/Common/Services/CachedAuthorizationHandler.cs b/src/Lumina.Presentation.Web/Common/Services/CachedAuthorizationHandler.cs index d9bc83c4..0dfcc01a 100644 --- a/src/Lumina.Presentation.Web/Common/Services/CachedAuthorizationHandler.cs +++ b/src/Lumina.Presentation.Web/Common/Services/CachedAuthorizationHandler.cs @@ -17,6 +17,7 @@ public class CachedAuthorizationHandler : DelegatingHandler { private readonly HybridCache _hybridCache; private const string AUTHORIZATION_ENDPOINT = "/auth/get-authorization"; + private const string LOGIN_ENDPOINT = "/api/v1/auth/login"; /// /// Initializes a new instance of the class with the specified hybrid cache. @@ -40,7 +41,11 @@ public class CachedAuthorizationHandler : DelegatingHandler string requestPath = request.RequestUri!.AbsolutePath; // if it's any endpoint other than the one for the authorization request, fire it away towards the original API service if (!requestPath.EndsWith(AUTHORIZATION_ENDPOINT, StringComparison.OrdinalIgnoreCase)) + { + if (requestPath.EndsWith(LOGIN_ENDPOINT)) // if login endpoint was hit, a new user is now present, delete previous cached permissions + await _hybridCache.RemoveAsync(AUTHORIZATION_ENDPOINT, cancellationToken).ConfigureAwait(false); return await base.SendAsync(request, cancellationToken).ConfigureAwait(false); + } // otherwise, check the hybrid cache to see if there is a cached authorization CachedResponseModel response = await _hybridCache.GetOrCreateAsync( AUTHORIZATION_ENDPOINT,