Class ValidateOtpCommandHandler
Handles the validation of one-time passwords (OTP) for user authentication.
public class ValidateOtpCommandHandler : ICommandHandler<ValidateOtpCommand, string>
- Inheritance
-
objectValidateOtpCommandHandler
- Implements
Remarks
This handler validates the OTP provided by the user against the stored OTP in the repository. If validation succeeds, the OTP is deleted from the repository to prevent reuse, the user is retrieved or created, and a JWT token is generated with ID proofing status included in the claims.
Constructors
ValidateOtpCommandHandler(IOtpRepository, IUserRepository, ILocalLoginTokenService, IValidator<ValidateOtpCommand>, ILogger<ValidateOtpCommandHandler>)
Handles the validation of one-time passwords (OTP) for user authentication.
public ValidateOtpCommandHandler(IOtpRepository otpRepository, IUserRepository userRepository, ILocalLoginTokenService jwtTokenService, IValidator<ValidateOtpCommand> validator, ILogger<ValidateOtpCommandHandler> logger)
Parameters
otpRepositoryIOtpRepositoryRepository for OTP storage and retrieval operations.
userRepositoryIUserRepositoryRepository for user data and ID proofing status.
jwtTokenServiceILocalLoginTokenServiceService for generating JWT tokens for authenticated users.
validatorIValidator<ValidateOtpCommand>Validator for the ValidateOtpCommand.
loggerILogger<ValidateOtpCommandHandler>Logger for tracking OTP validation attempts and results.
Remarks
This handler validates the OTP provided by the user against the stored OTP in the repository. If validation succeeds, the OTP is deleted from the repository to prevent reuse, the user is retrieved or created, and a JWT token is generated with ID proofing status included in the claims.
Methods
Handle(ValidateOtpCommand, CancellationToken)
public Task<Result<string>> Handle(ValidateOtpCommand command, CancellationToken cancellationToken = default)
Parameters
commandValidateOtpCommandcancellationTokenCancellationToken
Returns
- Task<Result<string>>