public ActionResult Index(Models.login log) { if (ModelState.IsValid) { try { using (merry_cliff_academyEntities db = new merry_cliff_academyEntities()) { var obj = db.logins.FirstOrDefault(a => a.username.Equals(log.username) && a.password.Equals(log.password)); if (obj != null) { Session["UserId"] = obj.loginId; Session["username"] = obj.username; return(RedirectToAction("Index", "Home")); } //============= } } catch (Exception e) { Console.WriteLine(e); throw; } } return(View(log)); }
public ActionResult Index(string choice, Models.login login) { if (choice == "1") { if (login.username == "admin" && login.password == "admin") { return(RedirectToAction("Index", "backup")); } else { return(RedirectToAction("Index", "maintenance")); } } else { if (login.username == "admin" && login.password == "admin") { return(RedirectToAction("Restore", "backup")); } else { return(RedirectToAction("Index", "maintenance")); } } }
public ActionResult Login(Models.login user) { if (ModelState.IsValid) { if (user.IsValid(user.UserName, user.Password)) //fetches wether the method is 'Accounts class' is true { return(RedirectToAction("Questionnaire", "Questionnaire")); } else { ModelState.AddModelError("", "Login data is incorrect!"); } } return(View(user)); }
public ActionResult Index(Models.login login) { if (ModelState.IsValid) { if (login.IsValid(login.username, login.password)) { FormsAuthentication.SetAuthCookie(login.username, login.RememberMe); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Login data is incorrect!"); } } return(View(login)); }
public ActionResult login(FormCollection collection, Models.login obj) { var dn = collection["Email"]; var mk = collection["Password"]; if (String.IsNullOrEmpty(dn)) { ViewData["Er1"] = "(*) Vui lòng nhập Email hoặc SĐT !"; } else if (String.IsNullOrEmpty(mk)) { ViewData["Er1"] = "(*) Vui lòng nhập mật khẩu !"; } else { try { Session["dangnhap"] = null; var data = from login in db.logins join acc in db.accounts on login.idUser equals acc.idUser join vt in db.positions on acc.idStaff equals vt.idStaff where (login.Email == dn || login.PhoneNumber == dn || acc.IDCard == dn) && login.Password == GetMD5(mk) select new { acc, vt.idLevel }; foreach (var user in data) { Session.RemoveAll(); user.acc.lastLogin = DateTime.Parse(DateTime.Now.ToString()); Session["dangnhap"] = user.acc.idUser; Session["idChucvu"] = user.acc.idStaff; Session["idLevel"] = user.idLevel; } db.SubmitChanges(); if (Session["dangnhap"] == null) { ViewData["Er1"] = "(*) Sai thông tin đăng nhập !"; return(View()); } return(RedirectToAction("thongbaotoanha")); } catch { ViewData["Er1"] = "(*) Đã xảy ra lỗi vui lòng đăng nhập lại !"; return(View()); } } return(View()); }
public ActionResult Index(Models.login user) { if (ModelState.IsValid) { if (login.IsValid(user.UserName, user.Password)) { HttpContext.Session.SetString("User", "active"); return(RedirectToAction("CrewMembers")); } else { ModelState.AddModelError("LogOnError", "O Utilizador ou Palavra chave esta errada"); //return RedirectToAction("Index"); } } // ModelState.AddModelError("LogOnError", "The user name or password provided is incorrect."); return(View(user)); }
// GET: maintenance public ActionResult Index() { Models.login login = new Models.login(); return(View(login)); }