public JsonResult JsonLogin(LoginModel model, string returnUrl) { if (ModelState.IsValid) { // Get user model Utilisateur user = uow.Utilisateur.GetByUserName(model.UserName); //if (user.Password == model.Password) if (Crypto.VerifyHashedPassword(user.Password, model.Password)) //if (user.Password == model.Password) //if (Membership.ValidateUser(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); this.Session["ConnectedUser"] = user; return Json(new { success = true, redirect = returnUrl }); } else { ModelState.AddModelError("", "Le login ou mot de passe est incorrect."); } } // If we got this far, something failed return Json(new { errors = GetErrorsFromModelState() }); }
public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid) { // Get user model Utilisateur user = uow.Utilisateur.GetByUserName(model.UserName); if (Crypto.VerifyHashedPassword(user.Password, model.Password)) //if (user.Password == model.Password) //if (Membership.ValidateUser(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); this.Session["ConnectedUser"] = user; if (Url.IsLocalUrl(returnUrl)) { return Redirect(returnUrl); } else { return RedirectToAction("Index", "Home"); } } else { ModelState.AddModelError("", "Le login ou mot de passe saisi est incorrect."); } } // If we got this far, something failed, redisplay form return View(model); }