diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-12-14 10:38:08 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-12-14 10:38:08 +0100 |
| commit | 2f7da902c9afeb3df31f59fa6c16223990f51eb6 (patch) | |
| tree | da258139ba2ef663a3061f00bbf7257ef723b958 /code/api/src/Endpoints/Internal/Root/ValidateRoute.cs | |
| parent | 0557de9f069dc620539409aced67e2ad61d25395 (diff) | |
| download | greatoffice-2f7da902c9afeb3df31f59fa6c16223990f51eb6.tar.xz greatoffice-2f7da902c9afeb3df31f59fa6c16223990f51eb6.zip | |
feat: Working email validation
Diffstat (limited to 'code/api/src/Endpoints/Internal/Root/ValidateRoute.cs')
| -rw-r--r-- | code/api/src/Endpoints/Internal/Root/ValidateRoute.cs | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/code/api/src/Endpoints/Internal/Root/ValidateRoute.cs b/code/api/src/Endpoints/Internal/Root/ValidateRoute.cs index 428a1a2..8f0882d 100644 --- a/code/api/src/Endpoints/Internal/Root/ValidateRoute.cs +++ b/code/api/src/Endpoints/Internal/Root/ValidateRoute.cs @@ -2,13 +2,15 @@ namespace IOL.GreatOffice.Api.Endpoints.Internal.Root; public class ValidateRoute : RouteBaseSync.WithRequest<ValidateRoute.QueryParams>.WithActionResult { - private readonly UserService _userService; - private readonly string _continueTo; + private readonly EmailValidationService _emailValidation; + private readonly string CanonicalFrontendUrl; + private readonly ILogger<ValidateRoute> _logger; - public ValidateRoute(UserService userService, VaultService vaultService) { - _userService = userService; + public ValidateRoute(VaultService vaultService, EmailValidationService emailValidation, ILogger<ValidateRoute> logger) { + _emailValidation = emailValidation; + _logger = logger; var c = vaultService.GetCurrentAppConfiguration(); - _continueTo = c.CANONICAL_FRONTEND_URL + "/portal?msg=emailValidated"; + CanonicalFrontendUrl = c.CANONICAL_FRONTEND_URL; } public class QueryParams @@ -19,7 +21,19 @@ public class ValidateRoute : RouteBaseSync.WithRequest<ValidateRoute.QueryParams [HttpGet("~/_/validate")] public override ActionResult Handle([FromQuery] QueryParams request) { - _userService.FulfillEmailValidationRequest(request.Id, LoggedInUser.Id); - return Redirect(_continueTo); + 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 |
