public ActionResult Login(CoreModel ULV, string returnUrl) { if (ModelState.IsValid) { CoreManager UM = new CoreManager(); Secur sr = new Secur(); string password = sr.Decrypt(UM.GUP(ULV.LoginName)); if (string.IsNullOrEmpty(password)) { ModelState.AddModelError("", "خطأ في اسم المستخدم أو كلمة المرور"); } else { if (ULV.Password.Equals(password)) { var role = (from q in db.vURoles where q.UserName.Equals(ULV.LoginName) select new { q.RoleName, q.UserID }).FirstOrDefault(); FormsAuthentication.SetAuthCookie(ULV.LoginName + "|" + role.UserID, false); return(RedirectToAction("Index", role.RoleName)); } else { ModelState.AddModelError("", "خطأ في كلمة المرور"); } } } return(View(ULV)); }
public JsonResult pwUpdat(int id, string pw, string npw) { Secur sr = new Secur(); var udept = am.Usrs.SingleOrDefault(v => v.UserID == id); if (pw == sr.Decrypt(udept.UserKey)) { udept.UserKey = sr.Encrypt(npw); am.SaveChanges(); return(Json(new { Success = true }, JsonRequestBehavior.AllowGet)); } else { var result = new { Success = false }; return(Json(result, JsonRequestBehavior.AllowGet)); } }