public UserStatus GetUserValidity(UserDetails u) { if (u.UserName == "Admin" && u.Password == "Admin") { return UserStatus.AuthenticatedAdmin; } return u.UserName == "Sukesh" && u.Password == "Sukesh" ? UserStatus.AuthentucatedUser : UserStatus.NonAuthenticatedUser; }
public ActionResult DoLogin(UserDetails u) { if (!ModelState.IsValid) return View("Login"); var bal = new EmployeeBusinessLayer(); //New Code Start var status = bal.GetUserValidity(u); if (status == UserStatus.AuthenticatedAdmin || status == UserStatus.AuthentucatedUser) { var isAdmin = status == UserStatus.AuthenticatedAdmin; FormsAuthentication.SetAuthCookie(u.UserName, false); Session["IsAdmin"] = isAdmin; return RedirectToAction("Index", "Employee"); } ModelState.AddModelError("CredentialError", "Invalid Username or Password"); return View("Login"); }