public ActionResult Login(signin login, string ReturnUrl = "") { string message = ""; business operation = new business(); if (operation.checkLogin(login)) { //var ticket = new FormsAuthenticationTicket(login.username, false, 20); //string encrypted = FormsAuthentication.Encrypt(ticket); //var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encrypted); Session["username"] = login.username; //var cookie = new HttpCookie("username", login.username); //cookie.HttpOnly = true; //Response.Cookies.Add(cookie); if (Url.IsLocalUrl(ReturnUrl)) { return(Redirect(ReturnUrl)); } else { return(RedirectToAction("Index", "Home")); } } else { message = "Invalid credential provided"; } ViewBag.Message = message; return(View()); }
public bool checkLogin(signin user) { var flag = from x in dc.Users.ToList() where (x.Username == user.username && x.Password == user.password) select x; if (flag.Count() == 1) { return(true); } return(false); }
protected void Login(object sender, EventArgs e) { string norp = ma.Value; string pass = pa.Value; signin ob = new signin(); string s = ob.Signin(norp, pass); if (s != "fail") { Session["name"] = s; Response.Redirect("home.aspx?name=" + s); } }
public ActionResult signin(signin p) { if (ModelState.IsValid) { string password = Encryptor.MD5Hash(p.Password); dataMeBookEntities dbo = new dataMeBookEntities(); QuanTriVien qtv = dbo.QuanTriViens.SingleOrDefault(x => x.TenDagNhapQTV == p.Username && x.MatKhauQTV == password); if (qtv != null) { Session["MaQTV"] = qtv.Ma_QTV; Session["TenDangNhapQTV"] = qtv.TenDagNhapQTV; Session["TenQTV"] = qtv.TenQTV; Session["Avatar"] = qtv.Avatar; HttpCookie CK_TKAD = new HttpCookie("TaiKhoanAdmin"); CK_TKAD.Value = qtv.TenDagNhapQTV; CK_TKAD.Expires = DateTime.Now.AddDays(1); HttpContext.Response.Cookies.Add(CK_TKAD); return(Redirect("~/Admin")); } Khach_Hang a = dbo.Khach_Hang.SingleOrDefault(x => x.TenDangNhap == p.Username && x.MatKhau == password); HttpCookie CK_TK = new HttpCookie("TaiKhoan"); CK_TK.Value = p.Username; CK_TK.Expires = DateTime.Now.AddMinutes(15); HttpContext.Response.Cookies.Add(CK_TK); if (a != null) { Session["TaiKhoan"] = a; Session["MaKhachHang"] = a.Ma_Khach_Hang; Session["HoKhachHang"] = a.HoKH; Session["TenKhachHang"] = a.TenKH; Session["TenDangNhap"] = a.TenDangNhap; return(Redirect("/")); } else { ViewBag.Errsignup = "Đang Nhập Sai Vui Lòng Đăng Nhập Lại"; } } else { ViewBag.Errsignup = "Đang Nhập Sai Vui Lòng Kiểm Tra Tài Khoản Mật Khẩu"; } return(View()); }
public Esignin singin(signin model) { Esignin user = Userservis.Signin(model); return(user); }