some changes

This commit is contained in:
john 2025-05-17 23:47:19 +02:00
parent 4ec9720541
commit b47bac67ca
37 changed files with 397 additions and 190 deletions

View file

@ -0,0 +1,20 @@
using Femto.Common.Infrastructure.Outbox;
using Femto.Modules.Auth.Contracts.Events;
using Femto.Modules.Auth.Data;
using Femto.Modules.Auth.Models.Events;
using MediatR;
namespace Femto.Modules.Auth.Models.DomainEventHandlers;
internal class UserWasCreatedHandler(Outbox<AuthContext> outbox)
: INotificationHandler<UserWasCreatedEvent>
{
public async Task Handle(UserWasCreatedEvent notification, CancellationToken cancellationToken)
{
await outbox.AddMessage(
notification.User.Id,
new UserWasCreatedIntegrationEvent(notification.User.Id, notification.User.Username),
cancellationToken
);
}
}

View file

@ -1,12 +1,11 @@
namespace Femto.Modules.Auth.Models;
public class UserSession
internal class UserSession
{
private static TimeSpan SessionTimeout { get; } = TimeSpan.FromMinutes(30);
private static TimeSpan ExpiryBuffer { get; } = TimeSpan.FromMinutes(5);
public string Id { get; private set; }
public DateTimeOffset Expires { get; private set; }
public bool ExpiresSoon => Expires < DateTimeOffset.UtcNow + ExpiryBuffer;
private UserSession() {}