Skip to content

Commit

Permalink
Require authorized users in SignalR hub
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-jimenezgarcia-ow committed Jun 23, 2019
1 parent 2bea745 commit ffea310
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/Hubs/QuestionHub.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.SignalR;
using server.Models;

Expand All @@ -15,6 +16,7 @@ public interface IQuestionHub
Task LiveChatMessageReceived(string username, string message);
}

[Authorize]
public class QuestionHub: Hub<IQuestionHub>
{
// No need to implement here the methods defined by IQuestionHub, their purpose is simply
Expand All @@ -31,7 +33,6 @@ public async Task LeaveQuestionGroup(Guid questionId)
{
await Groups.RemoveFromGroupAsync(Context.ConnectionId, questionId.ToString());
}

public async Task SendLiveChatMessage(string message)
{
await Clients.All.LiveChatMessageReceived(Context.UserIdentifier, message);
Expand Down

0 comments on commit ffea310

Please sign in to comment.