Example #1
0
        public JsonResult UpdPwd(int type, string oldpwd, string newpwd)
        {
            var    result = false;
            var    model  = CurrentUser;
            string msg    = "";

            if (type == 0 && Encrypt.GetEncryptPwd(oldpwd, CurrentUser.LoginName).ToLower() != CurrentUser.LoginPwd.ToLower())
            {
                msg = "旧密码错误,操作失败";
            }
            else if (type == 1 && !string.IsNullOrEmpty(CurrentUser.AccountPwd) &&
                     CurrentUser.AccountPwd.ToLower() != Encrypt.GetEncryptPwd(newpwd, CurrentUser.LoginName).ToLower())
            {
                msg = "资金密码错误,操作失败";
            }
            else if (type == 1 && string.IsNullOrEmpty(CurrentUser.AccountPwd) &&
                     CurrentUser.LoginPwd.ToLower() == Encrypt.GetEncryptPwd(newpwd, CurrentUser.LoginName).ToLower())
            {
                msg = "资金密码不能喝登陆密码一致,操作失败";
            }
            else
            {
                if (type == 0)
                {
                    result = M_UsersBusiness.SetAdminAccount(CurrentUser.UserID, CurrentUser.LoginName, newpwd);
                    if (result)
                    {
                        model.LoginPwd    = Encrypt.GetEncryptPwd(newpwd, CurrentUser.LoginName);
                        Session["Manage"] = model;
                    }
                }
                else
                {
                    result            = M_UsersBusiness.UpdateAccountPwd(CurrentUser.UserID, CurrentUser.LoginName, newpwd);
                    model.AccountPwd  = Encrypt.GetEncryptPwd(newpwd, CurrentUser.LoginName);
                    Session["Manage"] = model;
                }
            }
            JsonDictionary.Add("result", result);
            JsonDictionary.Add("ErrMsg", msg);
            return(new JsonResult
            {
                Data = JsonDictionary,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }