public ActionResult DefinePassword(ResetPasswordModel model) { var LanguageData = PageLanguageHelper.GetLanguageContent("User", "Login"); if (ModelState.IsValid) { var userAuth = UserAuthentificationBL.GetUserAuthentificationByToken(model.Token); var user = UserBL.GetUserById(userAuth.idUser); if (userAuth.IsValid ) { if (user != null) { if (model.NewPassword == model.RetypeNewPassword) { if (UserBL.ValidatePassword(model.NewPassword)) { UserBL.ChangePassword(user, model.NewPassword); UserAuthentificationBL.InvalidateToken(userAuth); var redirect = new System.Web.Routing.RouteValueDictionary(); redirect.Add("message", LanguageData.GetContent("mdp_changé")); redirect.Add("headerText", LanguageData.GetContent("mdp_suces")); redirect.Add("title", LanguageData.GetContent("mdp_changement")); //return RedirectToAction("Message", "Shared", redirect); LoginSimulation(GetLoggedUser(user.UserEmail, model.NewPassword)); return RedirectToAction("Dashboard", "Home", new { d = model.Direction }); } else { //ModelState.AddModelError(String.Empty, LanguageData.GetContent("mdp_criteria")); ModelState.AddModelError(string.Empty, LanguageData.GetContent("mot_de_passe_obligatoirement")); ModelState.AddModelError(string.Empty, LanguageData.GetContent("mot_de_passe_longueur_minimale")); ModelState.AddModelError(string.Empty, LanguageData.GetContent("mot_de_passe_uniquement_chiffre")); ModelState.AddModelError(string.Empty, LanguageData.GetContent("mot_de_passe_au_moins_2_chiffres")); ModelState.AddModelError(string.Empty, LanguageData.GetContent("mot_de_passe_sensible_ala_casse")); } } else ModelState.AddModelError(String.Empty, LanguageData.GetContent("mot_de_passe_not_match")); } } else model.IsTokenValid = false; } return View("DefinePassword", model); }
public ActionResult DefinePassword(String token) { UserBL.Logout(); ResetPasswordModel model = new ResetPasswordModel(); model.IsTokenValid = UserAuthentificationBL.IsTokenStillValid(token); if (model.IsTokenValid) { model.Token = token; var userAuth = UserAuthentificationBL.GetUserAuthentificationByToken(model.Token); var user = UserBL.GetUserById(userAuth.idUser); model.Username = user.UserLogin; if (!string.IsNullOrEmpty(Request.Params["d"])) model.Direction = Request.Params["d"]; } return View("DefinePassword", model); }