From f4df8c0c3b104118c577896a1cc12698733882d0 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 1 Aug 2025 02:04:10 +0800 Subject: [PATCH] :bug: Fix auth session cache made auth result missing perk subscriptions --- DysonNetwork.Pass/Auth/Auth.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/DysonNetwork.Pass/Auth/Auth.cs b/DysonNetwork.Pass/Auth/Auth.cs index 45c4e41..b64242a 100644 --- a/DysonNetwork.Pass/Auth/Auth.cs +++ b/DysonNetwork.Pass/Auth/Auth.cs @@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; using DysonNetwork.Pass.Auth.OidcProvider.Services; using DysonNetwork.Pass.Handlers; +using DysonNetwork.Pass.Wallet; using DysonNetwork.Shared.Cache; using SystemClock = NodaTime.SystemClock; @@ -42,6 +43,7 @@ public class DysonTokenAuthHandler( UrlEncoder encoder, AppDatabase database, OidcProviderService oidc, + SubscriptionService subscriptions, ICacheService cache, FlushBufferService fbs ) @@ -79,6 +81,9 @@ public class DysonTokenAuthHandler( if (session is not null) { + var perk = await subscriptions.GetPerkSubscriptionAsync(session.AccountId); + session.Account.PerkSubscription = perk?.ToReference(); + // Store in cache for future requests await cache.SetWithGroupsAsync( $"auth:{sessionId}", @@ -177,7 +182,8 @@ public class DysonTokenAuthHandler( // Verify signature var signature = Base64UrlDecode(parts[1]); - return rsa.VerifyData(payloadBytes, signature, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1); + return rsa.VerifyData(payloadBytes, signature, HashAlgorithmName.SHA256, + RSASignaturePadding.Pkcs1); } catch { @@ -232,7 +238,7 @@ public class DysonTokenAuthHandler( { var token = authHeader["Bearer ".Length..].Trim(); var parts = token.Split('.'); - + return new TokenInfo { Token = token,