public ActionResult Login(LoginModel model, string returnUrl) { //System.Data.DataTable dt = new System.Data.DataTable(); //dt = BLObj.GetUserbyEmail(model.Email); //string UserName = ""; ////dt = bl.GetEmailId(model.UserName); //if (dt.Rows.Count == 1) //{ // UserName = dt.Rows[0][1].ToString(); // // ViewBag.Success = "Your Token has been mail on your Email Account.Use it to reset password,follow provided link in mail to go to reset password page"; //} if (model.Password != null || model.Email != null) { //if (UserName != "") //{ if (CheckUserActiveORNOT(model.Email) == 1) { if (ModelState.IsValid && WebSecurity.Login(model.Email, model.Password, persistCookie: model.RememberMe)) { return RedirectToLocal(returnUrl); } else { ModelState.AddModelError("", "The email or password is incorrect."); } } else if (CheckUserActiveORNOT(model.Email) == 0) { ModelState.AddModelError("", "Your account has been deactivated"); } else { ModelState.AddModelError("", "Email id or password is incorrect."); } //} //else // ModelState.AddModelError("", "Email id or password is incorrect."); } else { ModelState.AddModelError("", "Email id or password is incorrect."); } return View(model); }
public ActionResult Login(LoginModel model, string returnUrl) { if (model.UserName != null) { if (CheckUserActiveORNOT(model.UserName) == 1) { if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe)) { return RedirectToLocal(returnUrl); } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } else if (CheckUserActiveORNOT(model.UserName) == 0) { ModelState.AddModelError("", "Your account has been deactivated"); } else { ModelState.AddModelError("", "Invalid UserName"); } } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } return View(model); }