public async Task <IActionResult> ForgotPassword(ForgotPasswordModel model) { if (ModelState.IsValid) { var user = await _userManager.FindByEmailAsync(model.Email); if (user != null) { var token = await _userManager.GeneratePasswordResetTokenAsync(user); var resetUrl = Url.Action("ResetPassword", "Account", new { token, email = user.Email }, Request.Scheme); _emailSender.AddReceiver(user.Email) .AddSubject("Reset your password for GeekCoding Site") .AddBody("Reset password link: " + resetUrl) .BuildAndSend(); //send resetUrl via mail } else { // email user and inform them that they do not have an account _emailSender.AddReceiver(model.Email) .AddSubject("Create account on GeekCoding Site") .AddBody("You don't have any account on our site. Please register!") .BuildAndSend(); } return(View("ResetPasswordSent")); } return(View()); }
private void InformUsersNewContest(string contestName) { var lstUsers = _userManager.Users.ToList(); foreach (var item in lstUsers) { _emailSender.AddReceiver(item.Email) .AddSubject($"Contest {contestName} ") .AddBody("A new contest will start soon!. Please check our page") .BuildAndSend(); } }