Class OtpController
- Namespace
- SEBT.Portal.Api.Controllers
- Assembly
- SEBT.Portal.Api.dll
Controller for handling one-time password (OTP) requests and validations.
[ApiController]
[Route("api/auth/otp")]
public class OtpController : ControllerBase
- Inheritance
-
objectControllerBaseOtpController
Constructors
OtpController(ILogger<OtpController>, IOptions<JwtSettings>, IHostEnvironment, IFeatureManager)
Controller for handling one-time password (OTP) requests and validations.
public OtpController(ILogger<OtpController> logger, IOptions<JwtSettings> jwtSettingsOptions, IHostEnvironment hostEnvironment, IFeatureManager featureManager)
Parameters
loggerILogger<OtpController>jwtSettingsOptionsIOptions<JwtSettings>hostEnvironmentIHostEnvironmentfeatureManagerIFeatureManager
Methods
RequestOtp(RequestOtpApiRequest, ICommandHandler<RequestOtpCommand>)
Request a one-time password (OTP) to be sent to the specified email address.
[HttpPost("request")]
[EnableRateLimiting("otp-policy")]
[ProducesResponseType(201)]
[ProducesResponseType(400)]
[ProducesResponseType(429)]
public Task<IActionResult> RequestOtp(RequestOtpApiRequest request, ICommandHandler<RequestOtpCommand> handler)
Parameters
requestRequestOtpApiRequestThe request containing the email address.
handlerICommandHandler<RequestOtpCommand>The command handler for processing the OTP request.
Returns
- Task<IActionResult>
A Created result if the OTP was sent successfully; otherwise, a BadRequest result.
ValidateOtp(ValidateOtpApiRequest, ICommandHandler<ValidateOtpCommand, string>)
Validate a one-time password (OTP) for the specified email address.
[HttpPost("validate")]
[EnableRateLimiting("otp-policy")]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
[ProducesResponseType(429)]
public Task<IActionResult> ValidateOtp(ValidateOtpApiRequest request, ICommandHandler<ValidateOtpCommand, string> handler)
Parameters
requestValidateOtpApiRequestThe request containing the email address and OTP code.
handlerICommandHandler<ValidateOtpCommand, string>The command handler for processing the OTP validation.
Returns
- Task<IActionResult>
204 No Content on success; the session JWT is set via HttpOnly cookie.