public ActionResult SaveReset(registered_user user, string password1, string password2) { if (!password1.Equals(password2)) { ModelState.AddModelError("same", "Passwords must be same."); return(View("ResetPassword", user)); } if (password1.Length < 4) { ModelState.AddModelError("same", "Minimum password length is 4 characters."); return(View("ResetPassword", user)); } using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { registered_user u = entities.registered_user.FirstOrDefault(e => e.login.Equals(user.login)); u.password = EncryptHelper.encryptPassword(password1); Logger.logToDB("Reset password to user " + u.login, entities, User.Identity.Name); entities.SaveChanges(); TempData["notifi"] = "true"; return(RedirectToAction("Index")); } }
public ActionResult Delete(registered_user user) { if (user == null) { return(RedirectToAction("Index")); } using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { registered_user u = entities.registered_user.FirstOrDefault(e => e.idregistered_user == user.idregistered_user); entities.registered_user.Remove(u); entities.SaveChanges(); return(RedirectToAction("Index")); } }
public ActionResult Singin(String login, String password, String remember) { bool remem = remember != null; if (new Frycz_pcdb_MemberShipProvider().ValidateUser(login, EncryptHelper.encryptPassword(password))) { using (var dc = new frycz_pcdbEntities()) { registered_user user = dc.registered_user.FirstOrDefault(u => u.login.Equals(login)); // var myCookie = new HttpCookie("myCookie"); user.last_login = DateTime.Now; dc.SaveChanges(); /* myCookie.Values.Add("id", user.idregistered_user.ToString()); * Response.Cookies.Add(myCookie); */FormsAuthentication.SetAuthCookie(login, remem); Session["user"] = user.login; } return(RedirectToAction("Index", "Home")); } TempData["error"] = "Login or password is invalid"; return(RedirectToAction("Index", "Login")); }
public ActionResult ResetPassword(registered_user user) { user.password = ""; return(View("ResetPassword", user)); }