// public LogAdmin(UserBus userBus) // { // _userBus = userBus; // } private void btnLogin_Click_1(object sender, EventArgs e) { if (txtUser.Text != "" && txtUser.TextLength > 2) { if (txtPass.Text != "") { UserBus user = new UserBus(); var response = user.Login(txtUser.Text, txtPass.Text); if (response.Ok) { //AbrirFormulario<frmCaja>(); //frmCaja frmCaja = new frmCaja(); //MessageBox.Show("Bienvenido " + response.Return.LoginName); //frmCaja.Show(); //frmCaja.FormClosed += Logout; this.Hide(); } else { msgError(response.GetFullErrorMessage); } } else { msgError("Ingresa contraseña."); } } else { msgError("Ingresa usuario."); } }
public IActionResult Login(UserView userView) { if (ValidateUserView(userView)) { UserView user = UserBus.Login(userView); if (user == null) { ViewBag.Error = "[Email or password invalid]"; return(View()); } SercurityManagerCuaSang.Login(HttpContext, user, "SCHEME_USER"); return(RedirectToAction("index", "home")); } ViewBag.Error = "[Data Invalid]"; return(View()); }
public ActionResult Login(LoginModel model) { ViewBag.GGSigninClientContent = ConfigurationManager.AppSettings["GgAppId"].ToString(); if (ModelState.IsValid) { var userBus = new UserBus(); var result = userBus.Login(model.MemberEmail, EncryptorMD5.MD5Hash(model.MemberPassword)); LoginModelDisplay loginModelDisplay = new LoginModelDisplay(); loginModelDisplay.MemberAccountId = db.Members.Where(m => m.MemberEmail == model.MemberEmail).Select(m => m.MemberId).SingleOrDefault(); loginModelDisplay.MemberEmail = model.MemberEmail; loginModelDisplay.RememberMe = model.RememberMe; loginModelDisplay.MemberName = db.Members.Where(m => m.MemberEmail == model.MemberEmail).Select(m => m.FullName).FirstOrDefault(); loginModelDisplay.MemberTypeId = result; if (result == 1 || result == 2) { Session.Remove(CommonConstants.USER_SESSION); Session.Add(CommonConstants.USER_SESSION, loginModelDisplay); return(RedirectToAction("Index", "ADHome")); } else if (result == 3) { Session.Remove(CommonConstants.USER_SESSION); Session.Add(CommonConstants.USER_SESSION, loginModelDisplay); return(RedirectToAction("Index", "Home", new { area = "" })); } else { ModelState.AddModelError("LoginCheck", "Đăng nhập không đúng"); return(View(model)); } } return(View(model)); }