using Domain.Entities; namespace Service.Auth; /// /// Represents the result of a user registration attempt. /// public record RegisterServiceReturn { /// /// Gets a value indicating whether tokens were issued for the newly created account. /// false when token generation failed, in which case and /// are empty. /// public bool IsAuthenticated { get; init; } = false; /// /// Gets a value indicating whether the registration confirmation email was sent successfully. /// public bool EmailSent { get; init; } = false; /// /// Gets the user account that was created. /// public UserAccount UserAccount { get; init; } /// /// Gets the issued access token, or an empty string if authentication was not completed. /// public string AccessToken { get; init; } = string.Empty; /// /// Gets the issued refresh token, or an empty string if authentication was not completed. /// public string RefreshToken { get; init; } = string.Empty; /// /// Initializes a new instance representing a successful registration with issued tokens. /// /// The newly created user account. /// The issued access token. /// The issued refresh token. /// Whether the confirmation email was sent successfully. public RegisterServiceReturn( UserAccount userAccount, string accessToken, string refreshToken, bool emailSent ) { IsAuthenticated = true; EmailSent = emailSent; UserAccount = userAccount; AccessToken = accessToken; RefreshToken = refreshToken; } /// /// Initializes a new instance representing a registration where tokens could not be issued. /// /// The newly created user account. public RegisterServiceReturn(UserAccount userAccount) { UserAccount = userAccount; } } /// /// Defines the operation for registering a new user account. /// public interface IRegisterService { /// /// Registers a new user account with the given password. /// /// The user account details to register. /// The plain-text password to hash and store for the new account. /// A describing the outcome of the registration. Task RegisterAsync( UserAccount userAccount, string password ); }