fork download
  1. [HttpPost]
  2. public JsonResult Auth(Models.AuthForm data)
  3. {
  4. if (ModelState.IsValid)
  5. {
  6. userdata userdata = null;
  7.  
  8. try
  9. {
  10. userdata = db.userdatas.Single(u => u.login == data.Login && u.password == data.Password);
  11. Response.AddHeader("Set-Cookie", "CookieName=CookieValue; path=/; HttpOnly");
  12. Response.SetCookie(new HttpCookie("session-id") { Value = Guid.NewGuid().ToString(), HttpOnly = true });
  13. Response.SetCookie(new HttpCookie("user-name") { Value = data.Login, HttpOnly = true });
  14. }
  15. catch { }
  16.  
  17. if (userdata != null) return Json(new Models.AuthResult { Value = "ok" }, JsonRequestBehavior.AllowGet);
  18. }
  19.  
  20. return Json(new Models.AuthResult { Value = "failed" }, JsonRequestBehavior.AllowGet);
  21. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty