using Femto.Modules.Auth.Application.Dto;
using Femto.Modules.Auth.Models;

namespace Femto.Modules.Auth.Application;

public interface IAuthService
{
    public Task<UserAndSession?> AuthenticateUserCredentials(
        string username,
        string password,
        CancellationToken cancellationToken = default
    );
    public Task<UserInfo?> GetUserWithId(
        Guid? userId,
        CancellationToken cancellationToken = default
    );
    public Task<Session> CreateNewSession(Guid userId);
    public Task<Session> CreateWeakSession(Guid userId);
    public Task<Session?> GetSession(string sessionId);
    public Task DeleteSession(string sessionId);

    public Task<UserAndSession> CreateUserWithCredentials(string username,
        string password,
        string signupCode,
        CancellationToken cancellationToken = default);

    public Task AddSignupCode(
        string code,
        string recipientName,
        CancellationToken cancellationToken = default
    );

    public Task<ICollection<SignupCodeDto>> GetSignupCodes(
        CancellationToken cancellationToken = default
    );

    Task<NewRememberMeToken> CreateRememberMeToken(Guid userId);
    Task<(UserInfo?, NewRememberMeToken?)> GetUserWithRememberMeToken(RememberMeToken rememberMeToken);
    Task DeleteRememberMeToken(RememberMeToken rememberMeToken);

    Task ChangePassword(Guid userId, string password, CancellationToken cancellationToken = default);
    Task InvalidateUserSessions(Guid userId, CancellationToken cancellationToken = default);
}

public record UserAndSession(UserInfo User, Session Session);