Class RequestOtpCommandHandler
Handles the request to generate and send a one-time password (OTP) to a user's email.
public class RequestOtpCommandHandler : ICommandHandler<RequestOtpCommand>
- Inheritance
-
objectRequestOtpCommandHandler
- 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
validatorIValidator<RequestOtpCommand>The validator used to validate the RequestOtpCommand.
otpGeneratorIOtpGeneratorServiceThe service used to generate OTP codes.
emailServiceIOtpSenderServiceThe service used to send the OTP to the user's email.
otpRepositoryIOtpRepositoryThe repository used to persist OTP codes.
loggerILogger<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
commandRequestOtpCommandcancellationTokenCancellationToken
Returns
- Task<Result>