public async Task <IActionResult> SendPasswordResetLink(RequestPasswordResetViewModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var user = await UserManagerAgent.FindByNameAsync(model.UserName).ConfigureAwait(false); if (user == null || !await UserManagerAgent.IsEmailConfirmedAsync(user).ConfigureAwait(false)) { ViewBag.Message = "Error while resetting your password!"; return(View("Error")); } var token = await UserManagerAgent.GeneratePasswordResetTokenAsync(user).ConfigureAwait(false); var resetLink = Url.Action("ResetPassword", "Account", new { token }, protocol: HttpContext.Request.Scheme); // code to email the above link string[] emailAddresses = { _appSettings.SMTP.AdminEmail, user.Email }; await _emailAgent.SendEmailAsync(_appSettings.SMTP.FromEmail, _appSettings.SMTP.FromEmail, emailAddresses, "Winemakers Software - Password Reset.", CreatePasswordResetEmail(resetLink), true, null).ConfigureAwait(false); // redirect to limbo page return(RedirectToAction("PasswordLimbo", "Account")); }