I am authenticating the user using JWT Tokens. Its working correctly, the Context.User
is populated correctly. The problem is its just one user, does the hub not have a user per connection?
In the OnNotification
method I want to cycle through all the current connections, verify if the user has permissions to see what I am about to send, then send if he/she has and not otherwise.
How can I acehieve this?
[Authorize]
public class NotifyHub : Hub {
private readonly MyApi _api;
public NotifyHub(MyApi api) {
_api = api;
_api.Notification += OnNotification;
}
private async void OnNotification(object sender, Notification notification) {
// can access Context.User here
await Clients.All.SendAsync("Notification", notification);
}
}