This commit is contained in:
john 2025-05-15 17:47:20 +02:00
parent 0dc41337da
commit 14fd359ea8
28 changed files with 156 additions and 52 deletions

View file

@ -3,4 +3,8 @@ using Femto.Modules.Auth.Application.Dto;
namespace Femto.Modules.Auth.Application.Commands.ValidateSession;
public record ValidateSessionCommand(string SessionId) : ICommand<ValidateSessionResult>;
/// <summary>
/// Validate an existing session, and then return either the current session, or a new one in case the expiry is further in the future
/// </summary>
/// <param name="SessionId"></param>
public record ValidateSessionCommand(string SessionId) : ICommand<ValidateSessionResult>;

View file

@ -1,6 +1,7 @@
using Femto.Common.Domain;
using Femto.Modules.Auth.Application.Dto;
using Femto.Modules.Auth.Data;
using Femto.Modules.Auth.Errors;
using Microsoft.EntityFrameworkCore;
namespace Femto.Modules.Auth.Application.Commands.ValidateSession;
@ -21,7 +22,7 @@ internal class ValidateSessionCommandHandler(AuthContext context)
);
if (user is null)
throw new DomainException("invalid session");
throw new InvalidSessionError();
var session = user.StartNewSession();