Exemplo n.º 1
0
        public async Task <IActionResult> VerifyEmail([FromBody] VerifyEmailRequestDto request)
        {
            if (!ModelState.IsValid)
            {
                return(ValidationProblem(ModelState));
            }

            // Retrieve user
            var user = await _userManager.FindByIdAsync(request.UserId);

            if (user == null)
            {
                return(BadRequest(new ErrorDto(ErrorDto.UserNotFound, "User not found")));
            }

            var result = await _userManager.ConfirmEmailAsync(user, request.Token);

            if (result.Succeeded)
            {
                return(Ok());
            }
            else
            {
                var errorDto = new ErrorDto();
                errorDto.AddIdentityErrors(result.Errors);
                return(BadRequest(errorDto));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> VerifyEmailAsync(VerifyEmailRequestDto request)
        {
            await _accountService.VerifyEmailAsync(request.Token);

            return(Ok(new { message = "Verification successful, you can now login" }));
        }