public HttpResponseMessage Login(LoginModel model) { try { if (ModelState.IsValid && WebSecurity.Login(model.Email, model.Password, persistCookie: model.RememberMe)) return new HttpResponseMessage(HttpStatusCode.OK); } catch(Exception ex) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest)); }
public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid && WebSecurity.Login(model.Email, model.Password, persistCookie: model.RememberMe)) { return RedirectToAction("Index", "Profile"); } ModelState.AddModelError("", "Wrong password or login"); return View(model); }