public ChangePasswordPage EnterRequiredFields(ChangePasswordDetails pwdDetails) { FindElement(existingPasswordTextbox).SendKeys(pwdDetails.ExistingPassword); FindElement(newPasswordTextbox).SendKeys(pwdDetails.NewPassword); FindElement(confirmPasswordTextbox).SendKeys(pwdDetails.ConfirmPassword); return(this); }
public IActionResult ChangePassword([Bind("Password,NewPassword,ReNewPassword")] ChangePasswordDetails changePasswordDetails) { try { if (ModelState.IsValid) { if (changePasswordDetails.NewPassword == changePasswordDetails.ReNewPassword) { var user = UserForChangePassword(changePasswordDetails.Password); if (user != null) { user.Password = changePasswordDetails.NewPassword; _context.Update(user); _context.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError(string.Empty, "סיסמה לא נכונה"); } } else { ModelState.AddModelError(string.Empty, "הסיסמאות שהוכנסו אינן תואמות"); } } } catch (Exception) { ModelState.AddModelError(string.Empty, "שגיאה התרחשה בעת החלפת הסיסמה"); } return(View(changePasswordDetails)); }
public ActionResult ChangePassword(ChangePasswordDetails changePasswordModel) { if (ModelState.IsValid) { if (Membership.ValidateUser(changePasswordModel.UserName, changePasswordModel.OldPassword)) { WebSecurity.ChangePassword(changePasswordModel.UserName, changePasswordModel.OldPassword, changePasswordModel.NewPassword); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("OldPassword", "wrong password"); } } return(View("ChangePassword", changePasswordModel)); }
public ActionResult ChangePassword() { ChangePasswordDetails password = new ChangePasswordDetails(); try { password = EmployeesLogic.GetChangePasswordModel(SessionData.UserId); } catch (Exception e) { LogsLogic.InsertLog(new Log() { Message = e.Message, StackTrace = e.StackTrace, StoryName = "ManagmentProject/Profile/ChangePassword" }); return(RedirectToAction("GeneralError", "Error", new { ErrorMessage = Error.ServerNotRespond })); } return(PartialView(password)); }
public async Task <int?> UpdatePasswordDetails(ChangePasswordDetails values) { int result = 0; ChangePasswordDetails changepwdmodel = new ChangePasswordDetails(); try { HttpClient hclient = new HttpClient(); hclient.BaseAddress = new Uri("http://insurethatapi.us-east-2.elasticbeanstalk.com/"); hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage Res = await hclient.GetAsync("api/ListOfPoliciesDetails?InsuredID=" + values.UserId + "");// Change Controller Name and fields // LogInDetails loginmodel = new LogInDetails(); if (Res.IsSuccessStatusCode) { //Storing the response details recieved from web api var EmpResponse = Res.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the Employee list changepwdmodel = JsonConvert.DeserializeObject <ChangePasswordDetails>(EmpResponse); MasterDataEntities db = new MasterDataEntities(); if (values.UserId.HasValue && values.UserId > 0) { // result = db.IT_IDC_UPDATE_USERPASSWORDDETAILS(values.UserID, values.Password, values.NewPassword); } else { } } } catch (Exception xp) { } finally { } return(result); }
// PUT: api/ChangePasswordDetails/5 public async Task <HttpResponseMessage> Put([FromBody] ChangePasswordDetails value) { ChangePasswordDetailsClass changedetails = new ChangePasswordDetailsClass(); ChangePasswordDetailsRef changepwdref = new ChangePasswordDetailsRef(); List <string> Errors = new List <string>(); try { changepwdref.ErrorMessage = new List <string>(); if (value != null) { var regexSpace = new Regex(@"\s"); if (regexSpace.IsMatch(value.UserName.Trim())) { Errors.Add("UserName having space,Name does not accept space"); } if (regexSpace.IsMatch(value.Password.Trim())) { Errors.Add("Password having space,Password does not accept space"); } if (regexSpace.IsMatch(value.NewPassword.Trim())) { Errors.Add("NewPassword having space,NewPassword does not accept space"); } if (regexSpace.IsMatch(value.RePassword.Trim())) { Errors.Add("RePassword having space,RePassword does not accept space"); } if (value.UserName.Trim() == string.Empty || value.UserName.Trim() == null || string.IsNullOrWhiteSpace(value.UserName.Trim())) { if (value.Email.Trim() == string.Empty || value.Email.Trim() == null || string.IsNullOrWhiteSpace(value.Email.Trim())) { Errors.Add("UserName Or Email any one is required"); } } if (value.Email.Trim() != null || value.Email.Trim() != string.Empty || value.UserName.Trim() != null || value.UserName.Trim() != string.Empty) { string specialCharacters = @"%!#$%^&*(-)?/><,:;'\|}]{[~`+=" + "\""; char[] specialCharactersArray = specialCharacters.ToCharArray(); int index = value.Email.IndexOfAny(specialCharactersArray); //index == -1 no special characters if (index == -1) { } else { Errors.Add("UserName & EmailID allows only '_' '.' '@' "); } if (regexSpace.IsMatch(value.Email)) { Errors.Add("Email having space,Email does not accept space"); } } if (value.Password.Trim() == value.NewPassword) { Errors.Add("Old and New password are equal,please give another password"); } if (value.NewPassword.Trim() == value.RePassword) { Errors.Add("New and Re password are Not equal,please give equal password"); } return(null); } } catch (Exception ex) { } return(null); }
// POST: api/ChangePasswordDetails public void Post([FromBody] ChangePasswordDetails value) { }
public async System.Threading.Tasks.Task <ActionResult> ForgetPassword(ForgotPasswordDetails frwd) { try { MasterDataEntities db = new MasterDataEntities(); Guid guid = Guid.NewGuid(); ChangePasswordDetails cpsd = new ChangePasswordDetails(); string confirmationLink = HttpContext.Request.Url.Scheme + "://" + HttpContext.Request.Url.Authority + Url.Action("ResetPassword", "Account", new { key = guid }); //ForgotPasswordClass fpd = new ForgotPasswordClass(); //fpd.SendEmail(frwd.Email, confirmationLink); //int? result = db.IT_InsertForgetPasswordCode(guid.ToString(), 1).SingleOrDefault(); string recepientEmail = frwd.Email; using (MailMessage mailMessage = new MailMessage()) { mailMessage.From = new MailAddress(ConfigurationManager.AppSettings["UName"]); mailMessage.Subject = "Forget Password"; mailMessage.Body = confirmationLink; mailMessage.IsBodyHtml = true; mailMessage.To.Add(new MailAddress(recepientEmail)); SmtpClient smtpp = new SmtpClient(); smtpp.Host = ConfigurationManager.AppSettings["Host"]; smtpp.EnableSsl = Convert.ToBoolean(ConfigurationManager.AppSettings["EnableSsl"]); System.Net.NetworkCredential NetworkCreda = new System.Net.NetworkCredential(); NetworkCreda.UserName = ConfigurationManager.AppSettings["UserName"]; NetworkCreda.Password = ConfigurationManager.AppSettings["Password"]; smtpp.UseDefaultCredentials = true; smtpp.Credentials = NetworkCreda; smtpp.Port = int.Parse(ConfigurationManager.AppSettings["Port"]); smtpp.Send(mailMessage); } //using (MailMessage mm = new MailMessage("*****@*****.**","*****@*****.**")) //{ // mm.Subject = "FP"; // mm.Body = confirmationLink; // mm.IsBodyHtml = false; // SmtpClient smtps = new SmtpClient("smtp.gmail.com", 587); // //smtps.Host = "smtp.gmail.com"; // //smtps.Host = "smtp.pacific.net.au"; // smtps.EnableSsl = true; // NetworkCredential NetworkCreda = new NetworkCredential("*****@*****.**", "sarkar23"); // smtps.UseDefaultCredentials = true; // smtps.Credentials = NetworkCreda; // smtps.Port = 587; // smtps.Send(mm); // // ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Email sent.');", true); //} //MailMessage mail = new MailMessage(); //mail.IsBodyHtml = false; //SmtpClient smtp = new SmtpClient(); //smtp.Host = "smtp.gmail.com"; //smtp.EnableSsl = true; //NetworkCredential NetworkCred = new NetworkCredential("*****@*****.**", "sarkar23"); //mail.Subject = "Forget Password"; //mail.Body = confirmationLink; //mail.From =new MailAddress("*****@*****.**"); //mail.To.Add("*****@*****.**"); //smtp.UseDefaultCredentials = true; //smtp.Credentials = NetworkCred; //smtp.Port = 587; //smtp.Send(mail); //SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); //mail.From = new MailAddress("*****@*****.**"); //mail.To.Add("*****@*****.**"); //mail.Subject = "Test Mail"; //mail.Body = "This is for testing SMTP mail from GMAIL"; //SmtpServer.Port = 587; //SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "$#5U09sfrdtyj34wqy"); //SmtpServer.EnableSsl = true; //SmtpServer.Send(mail); Session["Email"] = frwd.Email; ViewBag.SuccessMessage = "Email is been send successfully."; return(View()); } catch (Exception ex) { ViewBag.ErrorMessage = "Failed to sent email."; return(View()); } }