mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 23:52:50 -05:00
Allow self-hosted notifications to work for Login with Device approval (#2934)
* Added anonymous hub context. * Added anonymous hub to nginx setup. * Added deserialization options to ignore case on deserialization.
This commit is contained in:
@ -10,10 +10,12 @@ namespace Bit.Notifications;
|
||||
public class SendController : Controller
|
||||
{
|
||||
private readonly IHubContext<NotificationsHub> _hubContext;
|
||||
private readonly IHubContext<AnonymousNotificationsHub> _anonymousHubContext;
|
||||
|
||||
public SendController(IHubContext<NotificationsHub> hubContext)
|
||||
public SendController(IHubContext<NotificationsHub> hubContext, IHubContext<AnonymousNotificationsHub> anonymousHubContext)
|
||||
{
|
||||
_hubContext = hubContext;
|
||||
_anonymousHubContext = anonymousHubContext;
|
||||
}
|
||||
|
||||
[HttpPost("~/send")]
|
||||
@ -25,7 +27,7 @@ public class SendController : Controller
|
||||
var notificationJson = await reader.ReadToEndAsync();
|
||||
if (!string.IsNullOrWhiteSpace(notificationJson))
|
||||
{
|
||||
await HubHelpers.SendNotificationToHubAsync(notificationJson, _hubContext, null);
|
||||
await HubHelpers.SendNotificationToHubAsync(notificationJson, _hubContext, _anonymousHubContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public static class HubHelpers
|
||||
CancellationToken cancellationToken = default(CancellationToken)
|
||||
)
|
||||
{
|
||||
var notification = JsonSerializer.Deserialize<PushNotificationData<object>>(notificationJson);
|
||||
var notification = JsonSerializer.Deserialize<PushNotificationData<object>>(notificationJson, _deserializerOptions);
|
||||
switch (notification.Type)
|
||||
{
|
||||
case PushType.SyncCipherUpdate:
|
||||
|
Reference in New Issue
Block a user