public async Task <ActionResult <ViewModelResponse> > RequestPasswordChange(string email) { try { var user = await _userManager.FindByEmailAsync(email); if (user != null) { PasswordReminder password = new PasswordReminder() { IdUser = new Guid(user.Id), Token = Guid.NewGuid(), ExpiresAt = DateTime.Now.AddHours(1) }; _dbContext.PasswordReminder.Add(password); _dbContext.SaveChanges(); string emailTo = user.Email; string subject = "Solicitud cambio de contraseña en Hanged Draw"; string url = Request.Scheme + "://" + Request.Host.Value + "/api/User/ChangePassword"; string link = String.Format("<a target=\"_blank\" href=\"{1}/{0}/{2}\"> link </a>", password.Id, url, password.Token); string style = "style=\"color: red;\""; string styleP = "style=\"color: black;\""; string htmlString = $@"<html> <body> <h2 {style}>Hanged Draw</h2> <p {styleP} >Para cambiar su contraseña ingrese en el siguiente {link} </p> <br> </body> </html>"; bool a = await SendEmailAsync(emailTo, subject, htmlString); return(Json(new ViewModelResponse() { Error = false, Response = "Verifique su correo electrónico." })); } return(Json(new ViewModelResponse() { Error = true, Response = "El usuario no existe" })); } catch (Exception e) { return(Json(new ViewModelResponse() { Error = true, Response = String.Format("Ocurrio un error al intentar verificar el correo electrónico, intenta nueva mente. {0}", e.Message) })); } }
public void ClickOnForgotPasswordLink() { if (PasswordReminder.Displayed) { PasswordReminder.Click(); } else { throw new Exception("Element is not found or not clickable"); } }
public void Main() { PasswordReminder prMySql = new PasswordReminder(new MySQLConnection()); PasswordReminder prMsSql = new PasswordReminder(new MsSQLConnection()); }