feat: add club membership contract signing and city services

This commit is contained in:
masoodafar-web
2025-12-18 00:44:44 +03:30
parent 63f05e0883
commit 4330ec3726
38 changed files with 1583 additions and 25 deletions
@@ -0,0 +1,51 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
namespace FrontOffice.BFF.WebApi.Hubs;
/// <summary>
/// SignalR Hub for relaying token notifications from CMS to Frontend clients.
/// This hub is used by Frontend to receive token revocation/refresh notifications.
/// </summary>
[Authorize(Roles = "user")]
public class TokenRelayHub : Hub
{
private readonly ILogger<TokenRelayHub> _logger;
public TokenRelayHub(ILogger<TokenRelayHub> logger)
{
_logger = logger;
}
public override async Task OnConnectedAsync()
{
var userId = Context.User?.FindFirst("userId")?.Value;
if (!string.IsNullOrEmpty(userId))
{
// Subscribe this connection to the user's group for notifications
await Groups.AddToGroupAsync(Context.ConnectionId, $"user_{userId}");
_logger.LogInformation("Frontend client connected to TokenRelayHub: {ConnectionId}, UserId: {UserId}",
Context.ConnectionId, userId);
}
else
{
_logger.LogWarning("Frontend client connected without userId: {ConnectionId}", Context.ConnectionId);
}
await base.OnConnectedAsync();
}
public override async Task OnDisconnectedAsync(Exception? exception)
{
var userId = Context.User?.FindFirst("userId")?.Value;
if (!string.IsNullOrEmpty(userId))
{
await Groups.RemoveFromGroupAsync(Context.ConnectionId, $"user_{userId}");
}
_logger.LogInformation("Frontend client disconnected from TokenRelayHub: {ConnectionId}, Exception: {Exception}",
Context.ConnectionId, exception?.Message);
await base.OnDisconnectedAsync(exception);
}
}