From 1f98b86f5e263527ce1e6894f3a57f8beead955a Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Thu, 4 Apr 2024 22:50:07 +0200 Subject: [PATCH] [backend/signalr] Fix unauthenticated hub connections --- .../Hubs/Authentication/AuthenticationHelpers.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Iceshrimp.Backend/Hubs/Authentication/AuthenticationHelpers.cs b/Iceshrimp.Backend/Hubs/Authentication/AuthenticationHelpers.cs index 90ff8d4a..0175efcb 100644 --- a/Iceshrimp.Backend/Hubs/Authentication/AuthenticationHelpers.cs +++ b/Iceshrimp.Backend/Hubs/Authentication/AuthenticationHelpers.cs @@ -78,12 +78,12 @@ public class HubAuthorizationHandler( public class HubUserIdProvider(IHttpContextAccessor httpContextAccessor) : IUserIdProvider { - public string GetUserId(HubConnectionContext connection) + public string? GetUserId(HubConnectionContext connection) { if (httpContextAccessor.HttpContext == null) throw new Exception("HttpContext must not be null at this stage"); - return httpContextAccessor.HttpContext.GetUserOrFail().Id; + return httpContextAccessor.HttpContext.GetUser()?.Id; } }