private void AuthenticateUser(string username, string password) { BAL.Login bAL = new BAL.Login(); Models.LoginModel loginModel = new Models.LoginModel(); loginModel.Username = username; loginModel.Password = password; DataTable dt = bAL.checkUser(loginModel); foreach (DataRow row in dt.Rows) { int RetryAttempts = Convert.ToInt32(row["RetryAttempts"]); if (Convert.ToBoolean(row["AccountLocked"])) { lblMessage.Text = "Account locked. Please contact administrator"; } else if (RetryAttempts > 0) { int AttemptsLeft = (4 - RetryAttempts); lblMessage.Text = "Invalid user name and/or password. " + AttemptsLeft.ToString() + "attempt(s) left"; } else if (Convert.ToBoolean(row["Authenticated"])) { string UserId = (row["UserId"].ToString()); FormsAuthentication.RedirectFromLoginPage(UserId, cbRememberMe.Checked); } } }
public ActionResult LoginC(Models.Login login) { BAL.Login data = new BAL.Login(); data.Email = login.Email; data.Password = login.Password; LoginDAL dal = new LoginDAL(); bool status = dal.ValidateUser(data); if (status) { return(RedirectToAction("About")); } else { return(View()); } }