public ActionResult TTLogin(LoginModel objLoginModel, string returnUrl) { if (!ModelState.IsValid) { return(View("TTLogin")); } var userData = new LoginBl().AuthenticateUser(objLoginModel.UserName, Common.Encryption.Cryptography.Encrypt(objLoginModel.Password)); if (userData.IsValid) { User currentUser = new UserBl().GetUserByUserName(userData.UserName); Session["currentUser"] = currentUser; string serializedUser = new JavaScriptSerializer().Serialize(currentUser); FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket( 1, userData.UserName.ToString(), DateTime.Now, DateTime.Now.AddDays(7), false, serializedUser, "/"); Response.Cookies.Clear(); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(authTicket)); Response.SetCookie(cookie); return(RedirectToLocal(returnUrl)); } ModelState.AddModelError("", "Login Failed,Invalid Credentials"); return(View("Login")); }
protected void Button1_Click(object sender, EventArgs e) { ModelClasses.Login l1 = new ModelClasses.Login(); l1.Id = TextBox1.Text; l1.Password = TextBox2.Text; LoginBl lbl = new LoginBl(); }
public ActionResult AuthenticateLogin(string userName, string password) { var userData = new LoginBl().AuthenticateUser(userName, password); if (userData.IsValid) { FormsAuthentication.SetAuthCookie(userName, true); } return(Json(userData, JsonRequestBehavior.AllowGet)); }
public IHttpActionResult ConsultarUsuario(Usuario oUsuario) { try { LoginBl loginBl = new LoginBl(); var usuario = loginBl.ConsultarUsuario(oUsuario); return(Ok(new { success = true, usuario })); } catch (Exception e) { return(Ok(new { success = false })); } }