public ActionResult ResetPassword(ResetPasswordViewModel model) { if (PasswordValidation(model.Password) && PasswordValidation(model.ConfirmPassword) && model.Password == model.ConfirmPassword) { using (VolunteersDBEntities db = new VolunteersDBEntities()) { Volunteer currentUser = db.Volunteers.FirstOrDefault(u => u.GUID == model.Code); if (currentUser != null) { currentUser.Password = HashPassword(model.Password); db.SaveChanges(); return(View("ResetPasswordConfirmation")); } } } string message = "Passwords entered did not match input validation expectations. Make sure passwords are between 8-15 characters and that password and confirm password match."; ViewBag.Message = message; return(View(model)); }
public ActionResult ChangePhone(ChangePhoneViewModel model) { using (VolunteersDBEntities db = new VolunteersDBEntities()) { if (PhoneValidation(model.Phone)) { Volunteer currentUser = db.Volunteers.FirstOrDefault(u => u.Email == User.Identity.Name); if (currentUser != null) { currentUser.Phone = model.Phone; db.SaveChanges(); return(View("ChangePhoneConfirmation")); } } } string message = "Invalid phone number entered. Do not use - and make sure your phone number is 10 digits long."; ViewBag.Message = message; return(View()); }
public ActionResult ChangePassword(ChangePasswordViewModel model) { using (VolunteersDBEntities db = new VolunteersDBEntities()) { if (PasswordValidation(model.OldPassword) && PasswordValidation(model.NewPassword) && PasswordValidation(model.ConfirmNewPassword) && (model.NewPassword == model.ConfirmNewPassword)) { string hashPassword = HashPassword(model.OldPassword); Volunteer currentUser = db.Volunteers.FirstOrDefault(u => u.Email == User.Identity.Name && u.Password == hashPassword); if (currentUser != null) { currentUser.Password = HashPassword(model.NewPassword); db.SaveChanges(); return(View("ChangePasswordConfirmation")); } } } string message = "Passwords entered did not match input validation expectations. Make sure passwords are between 8-15 characters."; ViewBag.Message = message; return(View()); }
public ActionResult ChangeEmail(ChangeEmailViewModel model) { using (VolunteersDBEntities db = new VolunteersDBEntities()) { if (EmailValidation(model.Email) && PasswordValidation(model.Password)) { string hashPassword = HashPassword(model.Password); Volunteer currentUser = db.Volunteers.FirstOrDefault(u => u.Email == User.Identity.Name && u.Password == hashPassword); if (currentUser != null) { currentUser.Email = model.Email; db.SaveChanges(); FormsAuthentication.SetAuthCookie(currentUser.Email, true); return(View("ChangeEmailConfirmation")); } } } string message = "Invalid email address or password. Please try again."; ViewBag.Message = message; return(View()); }
public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model) { if (ModelState.IsValid) { using (VolunteersDBEntities db = new VolunteersDBEntities()) { if (EmailValidation(model.Email)) { Volunteer forgetUser = db.Volunteers.FirstOrDefault(u => u.Email == model.Email); if (forgetUser != null) { forgetUser.GUID = Guid.NewGuid().ToString(); db.SaveChanges(); SendEmail(forgetUser.Email, "Reset Password", "Your reset password link is http://" + Request.Url.Authority + "/Account/ResetPassword?code=" + forgetUser.GUID); return(View("ForgotPasswordConfirmation")); } } } } string message = "invalid email entered. Please try again."; ViewBag.Message = message; return(View(model)); }