Exemple #1
0
        public ActionResult ModifyPassword(ModifyPasswordModel model)
        {
            if (string.IsNullOrWhiteSpace(model.OldPassword) ||
                string.IsNullOrWhiteSpace(model.NewPassword) ||
                string.IsNullOrWhiteSpace(model.ConfirmPassword))
            {
                ModelState.AddModelError("", "请认真填写密码!");
                return(View());
            }


            string oldPassword = Lind.DDD.Utils.Encryptor.Utility.EncryptString(model.OldPassword, Lind.DDD.Utils.Encryptor.Utility.EncryptorType.MD5);
            string newPassword = Lind.DDD.Utils.Encryptor.Utility.EncryptString(model.NewPassword, Lind.DDD.Utils.Encryptor.Utility.EncryptorType.MD5);

            var old = userRepository.Find(i => i.LoginName == CurrentUser.UserName && i.Password == oldPassword);

            if (old == null)
            {
                ModelState.AddModelError("", "原密码不正确!");
                return(View());
            }

            if (model.NewPassword != model.ConfirmPassword)
            {
                ModelState.AddModelError("", "新密码和确认密码必须相同!");
                return(View());
            }

            old.Password = newPassword;
            userRepository.Update(old);
            ViewBag.Msg = "<span style='color: green;font-size: 1.1em;font-weight:bold;'>密码成功修改,请重新<a href='/AdminCommon/Logon'>登陆</a></span>";
            return(View());
        }
 /// <summary>
 /// 构造函数
 /// </summary>
 public ModifyPasswordViewModel()
 {
     CurrentDataModel = new ModifyPasswordModel()
     {
         Name = StaticData.CurrentUser.Name
     };
     CurrentDataModel.PropertyChanged += CurrentDataModel_PropertyChanged;
     initCommand();
 }
Exemple #3
0
        public ServiceResult <bool> ModifyPassword(ModifyPasswordModel model)
        {
            var result = new ServiceResult <bool>();

            new InvestorAccountComponent().ModifyPassword(this.GetUser(), model.OldPassword, model.NewPassword);
            result.Data = true;
            result.Successful();
            return(result);
        }
        public IHttpActionResult ModifyPassword(ModifyPasswordModel model)
        {
            var result = MemberBusiness.ModifyPassword(UserID, model.NewPassword, model.Code);

            if (!result.Success)
            {
                return(BadRequest(result.Message));
            }

            return(Ok());
        }
Exemple #5
0
        public JsonResult ModifyPassword(ModifyPasswordModel model)
        {
            string msg = ""; bool success;

            using (var db = new SysContext())
            {
                var oldUser = db.sys_user.Find(model.UserCode);
                if (oldUser != null && model.oldPassword == oldUser.Password)
                {
                    oldUser.Password = model.newPassword;
                    db.SaveChanges();
                    msg     = "修改成功";
                    success = true;
                }
                else
                {
                    success = false;
                    msg     = "原密码不正确";
                }
            }
            return(Json(new { success, msg }, JsonRequestBehavior.AllowGet));
        }
 public JsonResult ModifyPassword(ModifyPasswordModel ModelInfo)
 {
     try
     {
         bool b = GlobalController.ValidateUser(this.User.Identity.Name, ModelInfo.OldPassword);
         if (!b)
         {
             return(Json(ReturnInfo.Error("旧密码错误!")));
         }
         else
         {
             MembershipUser MembershipUser    = Membership.GetUser(this.User.Identity.Name);
             string         NewRandomPassword = MembershipUser.ResetPassword();
             MembershipUser.ChangePassword(NewRandomPassword, ModelInfo.NewPassword);
             return(Json(ReturnInfo.Success(string.Empty)));
         }
     }
     catch (Exception ex)
     {
         return(Json(ReturnInfo.Error(ex.Message), JsonRequestBehavior.AllowGet));
     }
 }
Exemple #7
0
 public ActionResult ModifyPassword(ModifyPasswordModel mpm)
 {
     DbModelDataContext db = DbContextFactory.Create();
     string username = HttpContext.User.Identity.Name;
     SIS_User user = db.SIS_User.Single(u => u.Username == username);
     string hashed = PasswordProvider.EncryptPassword(mpm.OriginPassword, user.Salt);
     if (mpm.NewPassword != mpm.ConfirmPassword)
     {
         ViewBag.Hint = "两次输入的密码不同。";
         ViewBag.Class = "alert alert-error";
         return View();
     }
     if (hashed != user.Password)
     {
         ViewBag.Hint = "原密码错误。";
         ViewBag.Class = "alert alert-error";
         return View();
     }
     else
     {
         string salt = PasswordProvider.GetSalt();
         user.Salt = salt;
         user.Password = PasswordProvider.EncryptPassword(mpm.NewPassword, salt);
         db.SubmitChanges();
         ViewBag.Hint = "密码已修改,请重新登陆。";
         ViewBag.Class = "alert alert-success";
         FormsAuthentication.SignOut();
         return View("LogOn");
     }
 }