public ActionResult CambioPassword() { PersonaModel utente = base.Session["utente"] as PersonaModel; UtenteCambioPasswordViewModel model = new UtenteCambioPasswordViewModel() { Password = utente.Persona.PASSWORD, ConfermaPassword = utente.Persona.PASSWORD }; return(base.View(model)); }
public ActionResult CambioPassword(UtenteCambioPasswordViewModel model) { if (base.ModelState.IsValid) { using (DatabaseContext db = new DatabaseContext()) { PersonaModel utente = base.Session["utente"] as PersonaModel; PBKDF2 crypto = new PBKDF2(); utente.Persona.PASSWORD = crypto.Compute(model.Password, utente.Persona.TOKEN_PASSWORD); db.Entry <PERSONA>(utente.Persona).State = EntityState.Modified; if (db.SaveChanges() > 0) { base.Session["utente"] = utente; base.TempData["salvato"] = true; } } } return(base.View(model)); }