blob: 998409400f92c995ca3c10efaf361d0e7ccdf1ef (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
namespace IOL.GreatOffice.Api.Endpoints.Internal.PasswordResetRequests;
/// <inheritdoc />
public class IsResetRequestValidRoute : RouteBaseAsync.WithRequest<Guid>.WithActionResult
{
private readonly ForgotPasswordService _forgotPasswordService;
/// <inheritdoc />
public IsResetRequestValidRoute(ForgotPasswordService forgotPasswordService) {
_forgotPasswordService = forgotPasswordService;
}
/// <summary>
/// Check if a given password reset request is still valid.
/// </summary>
/// <param name="id"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[AllowAnonymous]
[HttpGet("~/_/forgot-password-requests/is-valid")]
public override async Task<ActionResult> HandleAsync(Guid id, CancellationToken cancellationToken = default) {
var request = await _forgotPasswordService.GetRequestAsync(id, cancellationToken);
if (request == default) {
return NotFound();
}
return Ok(request.IsExpired == false);
}
}
|