public async Task <ActionResultDto> VerifyEmail(VerifyEmailDto verifyEmailInfo) { var result = new ActionResultDto(); try { var user = await _userManager.FindByIdAsync(verifyEmailInfo.Id); if (user != null) { var confirmEmailResult = await _userManager.ConfirmEmailAsync(user, verifyEmailInfo.Token); result.IsSuccess = confirmEmailResult.Succeeded; if (confirmEmailResult.Succeeded) { result.Message = "Email has been confirmed"; } else { result.Message = string.Join(" ", confirmEmailResult.Errors.Select(e => e.Description)); } } else { result.SetInfo(false, $"User with Id: {verifyEmailInfo.Id} not found"); } } catch (Exception ex) { _logger.Error(ex); result.SetInfo(false, ex.Message); } return(result); }
public async Task <IActionResult> OnPostAsync([FromBody] VerifyEmailDto dto) { if (!ModelState.IsValid) { return(await Task.FromResult(new JsonResult(new { Status = false, ErrorMessage = ModelState.Where(e => e.Value.Errors.Count > 0).Select(e => e.Value.Errors.First().ErrorMessage).First() }))); } var userId = _accountContext.UserId; var command = new VerifyEmailCommand(dto.Email, dto.Code); await _bus.SendCommand(command); if (_notifications.HasNotifications()) { var errorMessage = string.Join(";", _notifications.GetNotifications().Select(x => x.Content)); return(await Task.FromResult(new JsonResult(new { status = false, errorMessage }))); } return(await Task.FromResult(new JsonResult(new { status = true }))); }
public async Task <ActionResult <ControllerResponse <string> > > verifyEmail(VerifyEmailDto verify) { _logger.LogInformation("In POST verifyEmail"); await _userService.verifyEmail(verify.login, verify.token); _logger.LogInformation("after verifyEmail"); return(Ok(new ControllerResponse <string> { data = "Email verified" })); }
public async Task <ActionResultDto> VerifyEmail([FromBody] VerifyEmailDto model) { ActionResultDto result = null; try { result = await _userMngService.VerifyEmail(model); return(result); } catch (Exception ex) { result = new ActionResultDto(); result.SetInfo(false, ex.Message); } return(result); }
public async Task <IActionResult> VerifyEmail([FromBody] VerifyEmailDto verifyEmailDto) { if (!ModelState.IsValid) { return(new BadRequestObjectResult(ModelState)); } var command = new VerifyEmailCommand(verifyEmailDto.Email, verifyEmailDto.Code); var result = await _mediatr.Send(command); if (result.Value == false) { return(new BadRequestObjectResult(result.ErrorMessages)); } return(new OkResult()); }
private async Task <ContentResult> RenderVerifyEmailResult(VerifyEmailDto dto) { var res = await _mailer.RenderAsync(new VerifyEmailPage(dto)); return(Content(res, "text/html")); }