public HttpResponseMessage Authenticate(LoginData login) { //var username = form.Get("Username"); //var password = form.Get("Password"); string username = login.Username; string password = login.Password; bool authenticated = FormsAuthentication.Authenticate(username, password); var cookie = FormsAuthentication.GetAuthCookie(username, false); if (!authenticated) { return(Request.CreateResponse <bool>(HttpStatusCode.Unauthorized, false)); } var response = Request.CreateResponse <bool>(HttpStatusCode.OK, true); response.Headers.AddCookies(new CookieHeaderValue[1] { new CookieHeaderValue(cookie.Name, cookie.Value) }); return(response); }
public HttpResponseMessage Authenticate(LoginData login) { //var username = form.Get("Username"); //var password = form.Get("Password"); string username = login.Username; string password = login.Password; bool authenticated = FormsAuthentication.Authenticate(username, password); var cookie = FormsAuthentication.GetAuthCookie(username, false); if (!authenticated) return Request.CreateResponse<bool>(HttpStatusCode.Unauthorized, false); var response = Request.CreateResponse<bool>(HttpStatusCode.OK, true); response.Headers.AddCookies(new CookieHeaderValue[1] { new CookieHeaderValue(cookie.Name, cookie.Value) }); return response; }