Add complete user invitation system to enable multi-user tenants. Changes: - Created Invitation domain entity with 7-day expiration - Implemented InviteUserCommand with security validation - Implemented AcceptInvitationCommand (creates user + assigns role) - Implemented GetPendingInvitationsQuery - Implemented CancelInvitationCommand - Added TenantInvitationsController with tenant-scoped endpoints - Added public invitation acceptance endpoint to AuthController - Created database migration for invitations table - Registered InvitationRepository in DI container - Created domain event handlers for audit trail Security Features: - Cannot invite as TenantOwner or AIAgent roles - Cross-tenant validation on all endpoints - Secure token generation and hashing - RequireTenantAdmin policy for invite/list - RequireTenantOwner policy for cancel This UNBLOCKS 3 skipped Day 6 tests (RemoveUserFromTenant). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
31 lines
980 B
C#
31 lines
980 B
C#
using ColaFlow.Modules.Identity.Domain.Aggregates.Invitations.Events;
|
|
using MediatR;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace ColaFlow.Modules.Identity.Application.EventHandlers;
|
|
|
|
/// <summary>
|
|
/// Event handler for InvitationCancelledEvent - logs cancellation
|
|
/// </summary>
|
|
public class InvitationCancelledEventHandler : INotificationHandler<InvitationCancelledEvent>
|
|
{
|
|
private readonly ILogger<InvitationCancelledEventHandler> _logger;
|
|
|
|
public InvitationCancelledEventHandler(ILogger<InvitationCancelledEventHandler> logger)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
public Task Handle(InvitationCancelledEvent notification, CancellationToken cancellationToken)
|
|
{
|
|
_logger.LogInformation(
|
|
"Invitation cancelled: Email={Email}, Tenant={TenantId}",
|
|
notification.Email,
|
|
notification.TenantId);
|
|
|
|
// Future: Could notify invited user, track cancellation metrics, etc.
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|