public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {
                CurrentUser.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(model.ConfirmPassword, "MD5");
                this.GeneMgr.Update(CurrentUser);
                SaveSuccessMessage(Resources.ACC.User.User_PasswordChanged);
            }

            return View(model);
        }
Esempio n. 2
0
 public ActionResult _ChangePassword(int? Id)
 {
     if (Id.HasValue)
     {
         ChangePasswordModel changePasswordModel = new ChangePasswordModel();
         changePasswordModel.Id = (int)Id;
         return PartialView(changePasswordModel);
     }
     else
     {
         return HttpNotFound();
     }
 }
Esempio n. 3
0
        public ActionResult _ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {
                Regex r = new Regex("^(?:(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])|(?=.*[A-Z])(?=.*[a-z])(?=.*[^A-Za-z0-9])|(?=.*[A-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9])|(?=.*[a-z])(?=.*[0-9])(?=.*[^A-Za-z0-9])).{6,}|(?:(?=.*[A-Z])(?=.*[a-z])|(?=.*[A-Z])(?=.*[0-9])|(?=.*[A-Z])(?=.*[^A-Za-z0-9])|(?=.*[a-z])(?=.*[0-9])|(?=.*[a-z])(?=.*[^A-Za-z0-9])|(?=.*[0-9])(?=.*[^A-Za-z0-9])|).{8,}");

                if (!r.IsMatch(model.ConfirmPassword))
                {
                    BusinessException ex = new BusinessException();
                    ex.AddMessage(Resources.ACC.User.User_Regex);
                    SaveBusinessExceptionMessage(ex);
                }
                else
                {
                    User user = queryMgr.FindById<User>(model.Id);
                    user.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(model.ConfirmPassword, "MD5");
                    user.LastPasswordModifyDate = DateTime.Now;
                    this.genericMgr.UpdateWithTrim(user);
                    SaveSuccessMessage(Resources.ACC.User.User_PasswordChanged);
                }
            }

            return PartialView(model);
        }
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {
                Regex r = new Regex("^(?:(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])|(?=.*[A-Z])(?=.*[a-z])(?=.*[^A-Za-z0-9])|(?=.*[A-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9])|(?=.*[a-z])(?=.*[0-9])(?=.*[^A-Za-z0-9])).{6,}|(?:(?=.*[A-Z])(?=.*[a-z])|(?=.*[A-Z])(?=.*[0-9])|(?=.*[A-Z])(?=.*[^A-Za-z0-9])|(?=.*[a-z])(?=.*[0-9])|(?=.*[a-z])(?=.*[^A-Za-z0-9])|(?=.*[0-9])(?=.*[^A-Za-z0-9])|).{8,}");

                if (!r.IsMatch(model.ConfirmPassword))
                {
                    BusinessException ex = new BusinessException();
                    ex.AddMessage(Resources.ACC.User.User_Regex);
                    SaveBusinessExceptionMessage(ex);
                }
                else
                {
                    CurrentUser.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(model.ConfirmPassword, "MD5");
                    this.genericMgr.Update(CurrentUser);
                    SaveSuccessMessage(Resources.ACC.User.User_PasswordChanged);
                }
            }

            return View(model);
        }
Esempio n. 5
0
        public ActionResult _ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {
                User user = queryMgr.FindById<User>(model.Id);
                user.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(model.ConfirmPassword, "MD5");
                this.genericMgr.Update(user);
                SaveSuccessMessage(Resources.ACC.User.User_PasswordChanged);
            }

            return PartialView(model);
        }
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {

                bool changePasswordSucceeded = true;

                User user = CurrentUser;
                //securityMgr.ChangePassword(model.UserName, model.OldPassword, model.NewPassword);
                try
                {
                    this.securityMgr.ChangePassword(user.Code, string.Empty, model.NewPassword);
                    SaveSuccessMessage(Resources.ACC.User.User_PasswordChanged);
                    //User user = this.securityMgr.GetUser(model.UserName);
                    //Session.Add(WebConstants.UserSessionKey, user);
                }
                catch (BusinessException ex)
                {
                    //SaveSuccessMessage(Resources.ACC.User.User_PasswordChanged);
                    //ModelState.AddModelError(string.Empty, ex.Message);
                    SaveBusinessExceptionMessage(ex);
                }
                catch (Exception ex)
                {
                    //ModelState.AddModelError(string.Empty, ex.Message);
                    SaveErrorMessage(ex.Message);
                    //SaveBusinessExceptionMessage(ex);
                }

                //Regex r = new Regex("^(?:(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])|(?=.*[A-Z])(?=.*[a-z])(?=.*[^A-Za-z0-9])|(?=.*[A-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9])|(?=.*[a-z])(?=.*[0-9])(?=.*[^A-Za-z0-9])).{6,}|(?:(?=.*[A-Z])(?=.*[a-z])|(?=.*[A-Z])(?=.*[0-9])|(?=.*[A-Z])(?=.*[^A-Za-z0-9])|(?=.*[a-z])(?=.*[0-9])|(?=.*[a-z])(?=.*[^A-Za-z0-9])|(?=.*[0-9])(?=.*[^A-Za-z0-9])|).{8,}");

                //if (!r.IsMatch(model.ConfirmPassword))
                //{
                //    BusinessException ex = new BusinessException();
                //    ex.AddMessage(Resources.ACC.User.User_Regex);
                //    SaveBusinessExceptionMessage(ex);
                //}
                //else
                //{
                //    CurrentUser.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(model.ConfirmPassword, "MD5");
                //    this.genericMgr.Update(CurrentUser);
                //    SaveSuccessMessage(Resources.ACC.User.User_PasswordChanged);
                //}
            }

            return View(model);
        }
Esempio n. 7
0
        public ActionResult ChangePassword(ChangePasswordModel model, int siteId)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    PortalSetting portalSetting = this.portalSettingMgr.GetPortalSetting(siteId);
                    SecurityService.SecurityService securityService = new SecurityService.SecurityService();
                    securityService.Url = ServiceURLHelper.ReplaceServiceUrl(securityService.Url, portalSetting.SIServerAddress, portalSetting.SIPort.ToString());
                    if (string.IsNullOrWhiteSpace(model.OldPassword))
                    {
                        throw new BusinessException(" 旧密码不能为空. ");
                    }
                    securityService.ChangePassword(model.UserCode, model.OldPassword,model.NewPassword);
                    User user = this.securityMgr.GetUser(model.UserCode);
                    Session.Add(WebConstants.UserSessionKey, user);
                    string userToken = securityService.VerifyUserPasswordAndGetUserToken(user.Code, model.NewPassword);

                    if (!string.IsNullOrWhiteSpace(userToken))
                    {
                        return Redirect("http://" + portalSetting.WebServerAddress + ":" + portalSetting.WebPort + (string.IsNullOrWhiteSpace(portalSetting.WebVirtualPath) ? "" : ("/" + portalSetting.WebVirtualPath)) + "/Account/TokenLogin?userName="******"&userToken=" + userToken);
                    }
                }
                catch (BusinessException ex)
                {
                    SaveBusinessExceptionMessage(ex);
                }
                catch (SoapException ex)
                {
                    SaveErrorMessage(ex.Actor);
                    //SaveBusinessExceptionMessage(ex);
                }
                catch(Exception ex)
                {
                    SaveErrorMessage(ex.Message);
                    //SaveBusinessExceptionMessage(ex);
                }
            }
            return View(model);
        }
Esempio n. 8
0
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {
                bool changePasswordSucceeded = true;

                Regex r = new Regex("^(?:(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])|(?=.*[A-Z])(?=.*[a-z])(?=.*[^A-Za-z0-9])|(?=.*[A-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9])|(?=.*[a-z])(?=.*[0-9])(?=.*[^A-Za-z0-9])).{6,}|(?:(?=.*[A-Z])(?=.*[a-z])|(?=.*[A-Z])(?=.*[0-9])|(?=.*[A-Z])(?=.*[^A-Za-z0-9])|(?=.*[a-z])(?=.*[0-9])|(?=.*[a-z])(?=.*[^A-Za-z0-9])|(?=.*[0-9])(?=.*[^A-Za-z0-9])|).{8,}");

                if (!r.IsMatch(model.NewPassword))
                {
                    BusinessException ex = new BusinessException();
                    ex.AddMessage(Resources.ACC.User.User_Regex);
                    SaveBusinessExceptionMessage(ex);
                    changePasswordSucceeded = false;
                }

                //// ChangePassword will throw an exception rather
                ////than return false in certain failure scenarios.
                try
                {
                    CurrentUser.Password = model.NewPassword;
                    this.genericMgr.Update(CurrentUser);
                }
                catch (BusinessException ex)
                {
                    SaveBusinessExceptionMessage(ex);
                    changePasswordSucceeded = false;
                }
                catch (Exception)
                {
                    changePasswordSucceeded = false;
                }

                if (changePasswordSucceeded)
                {
                    return RedirectToAction("ChangePasswordSuccess");
                }
                ////else
                ////{
                ////    ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
                ////}
            }

            //// If we got this far, something failed, redisplay form
            return View(model);
        }
Esempio n. 9
0
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {
                try 
	            {
                    this.securityMgr.ChangePassword(model.UserCode,model.OldPassword,model.NewPassword); 
                    User user = this.securityMgr.GetUser(model.UserCode);
                    Session.Add(WebConstants.UserSessionKey, user);
                    return RedirectToAction("Default", "Main");
	            }
	            catch (BusinessException ex)
	            {
                    SaveBusinessExceptionMessage(ex);
	            }
            }
            return View(model);
        }
Esempio n. 10
0
        public ActionResult _ChangePassword(ChangePasswordModel model)
        {
            ModelState.Remove("OldPassword");
            if (ModelState.IsValid)
            {
                //Regex r = new Regex("^(?:(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])|(?=.*[A-Z])(?=.*[a-z])(?=.*[^A-Za-z0-9])|(?=.*[A-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9])|(?=.*[a-z])(?=.*[0-9])(?=.*[^A-Za-z0-9])).{6,}|(?:(?=.*[A-Z])(?=.*[a-z])|(?=.*[A-Z])(?=.*[0-9])|(?=.*[A-Z])(?=.*[^A-Za-z0-9])|(?=.*[a-z])(?=.*[0-9])|(?=.*[a-z])(?=.*[^A-Za-z0-9])|(?=.*[0-9])(?=.*[^A-Za-z0-9])|).{8,}");

                //if (!r.IsMatch(model.ConfirmPassword))
                //{
                //    BusinessException ex = new BusinessException();
                //    ex.AddMessage(Resources.ACC.User.User_Regex);
                //    SaveBusinessExceptionMessage(ex);
                //}
                try
                {
                    User user = base.genericMgr.FindById<User>(model.Id);
                    //user.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(model.ConfirmPassword, "MD5");
                    //this.genericMgr.UpdateWithNativeQuery("exec USP_Busi_ChangePassword ?,?",
                    //new object[] { user.Id, user.Password },
                    //new IType[] { NHibernateUtil.String, NHibernateUtil.String });
                    //SaveSuccessMessage(Resources.ACC.User.User_PasswordChanged);

                    securityMgr.ChangePassword(user.Code, string.Empty, model.ConfirmPassword);
                    SaveSuccessMessage(Resources.ACC.User.User_PasswordChanged);

                }
                catch (BusinessException ex)
                {
                    SaveBusinessExceptionMessage(ex);
                }
                catch (Exception ex)
                {
                    if (ex.InnerException != null)
                    {
                        if (ex.InnerException.InnerException != null)
                        {
                            SaveErrorMessage(ex.InnerException.InnerException.Message);
                        }
                        else
                        {
                            SaveErrorMessage(ex.InnerException.Message);
                        }
                    }
                    else
                    {
                        SaveErrorMessage(ex.Message);
                    }
                }
            }
            return PartialView(model);
        }
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            ModelState.Remove("OldPassword");
            if (ModelState.IsValid)
            {
                try
                {
                    securityMgr.ChangePassword(CurrentUser .Code, string.Empty, model.ConfirmPassword);
                    SaveSuccessMessage(Resources.ACC.User.User_PasswordChanged);
                }
                catch (BusinessException ex)
                {
                    SaveBusinessExceptionMessage(ex);
                }
                catch (Exception ex)
                {
                    if (ex.InnerException != null)
                    {
                        if (ex.InnerException.InnerException != null)
                        {
                            SaveErrorMessage(ex.InnerException.InnerException.Message);
                        }
                        else
                        {
                            SaveErrorMessage(ex.InnerException.Message);
                        }
                    }
                    else
                    {
                        SaveErrorMessage(ex.Message);
                    }
                }
            }

            return View(model);
        }
Esempio n. 12
0
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {
                //// ChangePassword will throw an exception rather
                ////than return false in certain failure scenarios.
                bool changePasswordSucceeded = true;

                try
                {
                    CurrentUser.Password = model.NewPassword;
                    this.GenericMgr.Update(CurrentUser);
                }
                catch (BusinessException ex)
                {
                    SaveBusinessExceptionMessage(ex);
                    changePasswordSucceeded = false;
                }
                catch (Exception)
                {
                    changePasswordSucceeded = false;
                }

                if (changePasswordSucceeded)
                {
                    return RedirectToAction("ChangePasswordSuccess");
                }
                ////else
                ////{
                ////    ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
                ////}
            }

            //// If we got this far, something failed, redisplay form
            return View(model);
        }