Table of Contents

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
object
ControllerBase
OtpController

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

logger ILogger<OtpController>
jwtSettingsOptions IOptions<JwtSettings>
hostEnvironment IHostEnvironment
featureManager IFeatureManager

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

request RequestOtpApiRequest

The request containing the email address.

handler ICommandHandler<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

request ValidateOtpApiRequest

The request containing the email address and OTP code.

handler ICommandHandler<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.