[backend/signalr] Fix unauthenticated hub connections
This commit is contained in:
parent
22cf408d6c
commit
1f98b86f5e
1 changed files with 2 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue