public ActionResult PageLock() { Users user = db.Userses.Single(a => a.UserName == User.Identity.Name); AccountLockViewModel u = new AccountLockViewModel() { FullName = user.FullName, UserName = user.UserName, Email = user.Email }; FormsAuthentication.SignOut(); return(View(u)); }
public ActionResult PageLock(AccountLockViewModel u) { if (ModelState.IsValid) { string pass = FormsAuthentication.HashPasswordForStoringInConfigFile(u.Password, "MD5"); Users userfind = db.Userses.SingleOrDefault(a => a.Email == u.Email && a.Password == pass); if (userfind != null) { FormsAuthentication.SetAuthCookie(userfind.UserName, false); return(Redirect("/Admin/")); } else { ModelState.AddModelError("Password", "رمز عبور وارد شده معتبر نمی باشد!"); } } return(View(u)); }