public override bool ValidateUser(string username, string password) { UcetDao ucetDao = new UcetDao(); Ucet ucet = ucetDao.GetByLoginAndPassword(username, password); return(ucet != null); }
public ActionResult zmenaHesla(string pasOld, string pasNew, string pasNewNew) { UcetDao ucetDao = new UcetDao(); MD5 md5 = new MD5CryptoServiceProvider(); Byte[] originalBytes = ASCIIEncoding.Default.GetBytes(pasOld); Byte[] encodedBytes = md5.ComputeHash(originalBytes); pasOld = BitConverter.ToString(encodedBytes); if (pasNew == pasNewNew) { try { Ucet ucet = ucetDao.GetByLoginAndPassword(User.Identity.Name, pasOld); if (ucet.Heslo == pasOld) { md5 = new MD5CryptoServiceProvider(); originalBytes = ASCIIEncoding.Default.GetBytes(pasNew); encodedBytes = md5.ComputeHash(originalBytes); String newpassword = BitConverter.ToString(encodedBytes); ucet.Heslo = newpassword; ucetDao.Update(ucet); TempData["zprava"] = "Změna hesla byla provedena."; return(RedirectToAction("DetailUctu")); } } catch (Exception e) { TempData["zprava"] = "Staré heslo nesouhlasí"; return(RedirectToAction("DetailUctu")); } } TempData["zprava"] = "Změna hesla nebyla provede. Nové heslo a potvrzení nového hesla není stejné"; return(RedirectToAction("DetailUctu")); }