public ActionResult Login(LoginModel model, string returnUrl) { var telemetryClient = new Microsoft.ApplicationInsights.TelemetryClient(); TraceTelemetry traceSample = new TraceTelemetry(); if (ModelState.IsValid && WebSecurity.Login( model.UserName, model.Password, persistCookie: model.RememberMe)) { // Migrate the user's shopping cart MigrateShoppingCart(model.UserName); //Sample Trace telemetry traceSample.Message = "Login succesfull"; traceSample.SeverityLevel = SeverityLevel.Information; telemetryClient.TrackTrace(traceSample); return RedirectToLocal(returnUrl); } //Sample Trace telemetry traceSample.Message = "Login failed"; traceSample.SeverityLevel = SeverityLevel.Information; telemetryClient.TrackTrace(traceSample); // If we got this far, something failed, redisplay form ModelState.AddModelError("", "The user name or password provided is incorrect."); return View(model); }
public bool Put(LoginModel model) { if (ModelState.IsValid) { WebSecurity.CreateUserAndAccount(model.UserName, model.Password); return Post(model); } return false; }
public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe)) { return RedirectToLocal(returnUrl); } // If we got this far, something failed, redisplay form ModelState.AddModelError("", "The user name or password provided is incorrect."); return View(model); }
public bool Post(LoginModel model) { var validCredentials = model != null && ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password); HttpContext.Current.Response.Cookies.Remove(".ASPXAUTH"); return validCredentials; }
public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe)) { return RedirectToLocal(returnUrl); } // Si llegamos a este punto, es que se ha producido un error y volvemos a mostrar el formulario ModelState.AddModelError("", "El nombre de usuario o la contraseña especificados son incorrectos."); return View(model); }