diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2023-02-25 13:15:44 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2023-02-25 13:15:44 +0100 |
| commit | 900bb5e845c3ad44defbd427cae3d44a4a43321f (patch) | |
| tree | df3d96a93771884add571e82336c29fc3d9c7a1c /code/api/src/Endpoints/Internal/Root/ValidateRoute.cs | |
| download | greatoffice-900bb5e845c3ad44defbd427cae3d44a4a43321f.tar.xz greatoffice-900bb5e845c3ad44defbd427cae3d44a4a43321f.zip | |
feat: Initial commit
Diffstat (limited to 'code/api/src/Endpoints/Internal/Root/ValidateRoute.cs')
| -rw-r--r-- | code/api/src/Endpoints/Internal/Root/ValidateRoute.cs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/code/api/src/Endpoints/Internal/Root/ValidateRoute.cs b/code/api/src/Endpoints/Internal/Root/ValidateRoute.cs new file mode 100644 index 0000000..8f0882d --- /dev/null +++ b/code/api/src/Endpoints/Internal/Root/ValidateRoute.cs @@ -0,0 +1,39 @@ +namespace IOL.GreatOffice.Api.Endpoints.Internal.Root; + +public class ValidateRoute : RouteBaseSync.WithRequest<ValidateRoute.QueryParams>.WithActionResult +{ + private readonly EmailValidationService _emailValidation; + private readonly string CanonicalFrontendUrl; + private readonly ILogger<ValidateRoute> _logger; + + public ValidateRoute(VaultService vaultService, EmailValidationService emailValidation, ILogger<ValidateRoute> logger) { + _emailValidation = emailValidation; + _logger = logger; + var c = vaultService.GetCurrentAppConfiguration(); + CanonicalFrontendUrl = c.CANONICAL_FRONTEND_URL; + } + + public class QueryParams + { + [FromQuery] + public Guid Id { get; set; } + } + + [HttpGet("~/_/validate")] + public override ActionResult Handle([FromQuery] QueryParams request) { + var isFulfilled = _emailValidation.FulfillEmailValidationRequest(request.Id, LoggedInUser.Id); + if (!isFulfilled) { + _logger.LogError("Email validation fulfillment failed for request {requestId} and user {userId}", request.Id, LoggedInUser.Id); + return StatusCode(400, $""" +<html> +<body> +<h3>The validation could not be completed</h3> +<p>We are working on fixing this, in the meantime, have patience.</p> +<a href="{CanonicalFrontendUrl}">Click here to go back to {CanonicalFrontendUrl}</a> +</body> +"""); + } + + return Redirect(CanonicalFrontendUrl + "/portal?msg=emailValidated"); + } +}
\ No newline at end of file |
