public async Task <IActionResult> OnPostAsync() { if (ModelState.IsValid) { var user = await _userManager.FindByEmailAsync(Input !.Email); if (user == null || !(await _userManager.IsEmailConfirmedAsync(user))) { _logger.LogWarning($"User {Input!.Email} does not exist or is not confirmed."); var noUserEvent = new InvalidUserEvent(Input !.Email !); await _dispatcher.Dispatch(noUserEvent); // Don't reveal that the user does not exist or is not confirmed return(RedirectToPage("./ForgotPasswordConfirmation")); } // For more information on how to enable account confirmation and password reset please // visit https://go.microsoft.com/fwlink/?LinkID=532713 var code = await _userManager.GeneratePasswordResetTokenAsync(user); code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); var callbackUrl = Url.Page( "/Account/ResetPassword", pageHandler: null, values: new { code }, protocol: Request.Scheme); if (string.IsNullOrEmpty(callbackUrl)) { throw new Exception("Callback URL is null or empty."); } _logger.LogInformation("Sending password reset request with URL " + callbackUrl); await _emailSender.SendEmailAsync( Input.Email, "Reset Password", $"Please reset your password by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); var newEvent = new PasswordResetEvent(Input.Email !); await _dispatcher.Dispatch(newEvent); return(RedirectToPage("./ForgotPasswordConfirmation")); } return(Page()); }
public void Apply(TReadModel readModel, TAggregateRootEventInterface evt) { ReadModel = readModel; EventDispatcher.Dispatch(evt); ReadModel = null; }
public void ApplyEvent(TComponentEventInterface @event) { _eventDispatcher.Dispatch(@event); }