1
0
mirror of https://github.com/bitwarden/server synced 2025-12-29 06:33:43 +00:00
Files
server/src/Hub/SyncHub.cs
2018-08-02 12:14:33 -04:00

34 lines
1.1 KiB
C#

using System;
using System.Threading.Tasks;
using Bit.Core;
using Microsoft.AspNetCore.Authorization;
namespace Bit.Hub
{
[Authorize("Application")]
public class SyncHub : Microsoft.AspNetCore.SignalR.Hub
{
public override async Task OnConnectedAsync()
{
var currentContext = new CurrentContext();
currentContext.Build(Context.User);
foreach(var org in currentContext.Organizations)
{
await Groups.AddToGroupAsync(Context.ConnectionId, $"Organization_{org.Id}");
}
await base.OnConnectedAsync();
}
public override async Task OnDisconnectedAsync(Exception exception)
{
var currentContext = new CurrentContext();
currentContext.Build(Context.User);
foreach(var org in currentContext.Organizations)
{
await Groups.RemoveFromGroupAsync(Context.ConnectionId, $"Organization_{org.Id}");
}
await base.OnDisconnectedAsync(exception);
}
}
}