Table of Contents

Class RequestOtpCommandHandler

Namespace
SEBT.Portal.UseCases.Auth
Assembly
SEBT.Portal.UseCases.dll

Handles the request to generate and send a one-time password (OTP) to a user's email.

public class RequestOtpCommandHandler : ICommandHandler<RequestOtpCommand>
Inheritance
object
RequestOtpCommandHandler
Implements

Remarks

This handler validates the incoming command, generates a new OTP code, persists it to the repository, and sends it to the user via email.

Constructors

RequestOtpCommandHandler(IValidator<RequestOtpCommand>, IOtpGeneratorService, IOtpSenderService, IOtpRepository, ILogger<RequestOtpCommandHandler>)

Handles the request to generate and send a one-time password (OTP) to a user's email.

public RequestOtpCommandHandler(IValidator<RequestOtpCommand> validator, IOtpGeneratorService otpGenerator, IOtpSenderService emailService, IOtpRepository otpRepository, ILogger<RequestOtpCommandHandler> logger)

Parameters

validator IValidator<RequestOtpCommand>

The validator used to validate the RequestOtpCommand.

otpGenerator IOtpGeneratorService

The service used to generate OTP codes.

emailService IOtpSenderService

The service used to send the OTP to the user's email.

otpRepository IOtpRepository

The repository used to persist OTP codes.

logger ILogger<RequestOtpCommandHandler>

The logger for recording errors and diagnostic information.

Remarks

This handler validates the incoming command, generates a new OTP code, persists it to the repository, and sends it to the user via email.

Methods

Handle(RequestOtpCommand, CancellationToken)

public Task<Result> Handle(RequestOtpCommand command, CancellationToken cancellationToken)

Parameters

command RequestOtpCommand
cancellationToken CancellationToken

Returns

Task<Result>