Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using System.Linq;
  2. using System.Security.Claims;
  3. using Microsoft.AspNetCore.SignalR;
  4.  
  5. namespace Web.Telephony.Realtime.Services.SignalR
  6. {
  7.     public class UserIdProvider : IUserIdProvider
  8.     {
  9.         public string GetUserId(HubConnectionContext connection)
  10.         {
  11.             var claimsIdentity = connection.User.Identity as ClaimsIdentity;
  12.             var userId = claimsIdentity?.Claims?.FirstOrDefault(x => x.Type == "sub")?.Value;
  13.             return userId;
  14.         }
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement