public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model) { if (ModelState.IsValid) { var user = await UserManager.FindByNameAsync(model.Email); if (user == null) { // Don't reveal that the user does not exist or is not confirmed return(Json("<div class='alert alert-success'>Success</div>")); } // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); //send email var recipient = new EmailRecipient(user.Email); var content = new EmailContent() .Title("Password Reset") .Button(callbackUrl, "#32c5d2", "#FFF", "Password Reset"); new Email(recipient, "Password Reset", content.ToHtml()).Send(); return(Json("<div class='alert alert-success'>Email sent</div>")); } // If we got this far, something failed, redisplay form return(Json("<div class='alert alert-danger'>FAILED</div>")); }
public async Task <ActionResult> ContentSources(RegistrationIndexViewModel model) { if (!ModelState.IsValid) { return(View()); } var registration = await _repo.ContentSourceRegistrationRequests.AddOrUpdateAndSaveAsync(new ContentSourceRegistrationRequest() { Email = model.Email }); var recipient = new EmailRecipient(model.Email); var content = new EmailContent() .Title("Fanword Content Sources") .Paragraph("Thank you for your interest in being a content source on Fanword. Click the link below to complete your registration.") .Button(Url.Action("ContentSourceRegistration", "Registration", new { id = registration.Id }, Request.Url.Scheme), "#32c5d2", "#FFF", "Register"); var email = new Email(recipient, "Fanword Content Source Sign-Up", content.ToHtml()); email.Send(); return(RedirectToAction("InitialContentSourcesRegistrationComplete")); }