示例#1
0
        private string SetPassWord(string pID, string pOldPWD, string pNewPWD)
        {
            string error    = "";
            string pNewPass = MD5Helper.Encryption(pNewPWD);

            //pOldPWD = MD5Helper.Encryption(pOldPWD);
            pOldPWD = EncryptManager.Hash(pOldPWD, HashProviderType.MD5);
            string res = "{success:false,msg:'保存失败'}";
            //组装参数
            UserInfo entity     = new UserInfo();
            var      serviceBll = new cUserService(CurrentUserInfo);

            entity = serviceBll.GetUserById(CurrentUserInfo, pID);
            string apPwd = serviceBll.GetPasswordFromAP(CurrentUserInfo.ClientID, pID);

            //if (pOldPWD == entity.User_Password)
            if (pOldPWD == apPwd)
            {
                entity.userRoleInfoList = new cUserService(CurrentUserInfo).GetUserRoles(pID, PageBase.JITPage.GetApplicationId());
                entity.User_Password    = pNewPass;
                entity.ModifyPassword   = true;
                //new cUserService(CurrentUserInfo).SetUserInfo(entity, entity.userRoleInfoList, out error);
                bool bReturn = serviceBll.SetUserPwd(CurrentUserInfo, pNewPass, out error);
                res = "{success:true,msg:'" + error + "'}";
            }
            else
            {
                res = "{success:false,msg:'旧密码不正确'}";
            }
            return(res);
        }
示例#2
0
        private string SetPassWord(string pRequest)
        {
            var    rp = pRequest.DeserializeJSONTo <APIRequest <SetPassWordRP> >();
            var    loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);
            string error    = "";
            string pNewPass = MD5Helper.Encryption(rp.Parameters.pNewPWD);

            //pOldPWD = MD5Helper.Encryption(pOldPWD);
            rp.Parameters.pOldPWD = EncryptManager.Hash(rp.Parameters.pOldPWD, HashProviderType.MD5);
            string res = "{\"success\":\"false\",\"msg\":\"保存失败\"}";

            //组装参数
            JIT.CPOS.BS.Entity.User.UserInfo entity = new JIT.CPOS.BS.Entity.User.UserInfo();
            var serviceBll = new cUserService(loggingSessionInfo);

            entity = serviceBll.GetUserById(loggingSessionInfo, rp.Parameters.pID);
            string apPwd = serviceBll.GetPasswordFromAP(loggingSessionInfo.ClientID, rp.Parameters.pID);

            //if (pOldPWD == entity.User_Password)
            if (rp.Parameters.pOldPWD == apPwd)
            {
                entity.userRoleInfoList = new cUserService(loggingSessionInfo).GetUserRoles(rp.Parameters.pID);//, PageBase.JITPage.GetApplicationId()
                entity.User_Password    = pNewPass;
                entity.ModifyPassword   = true;
                //new cUserService(CurrentUserInfo).SetUserInfo(entity, entity.userRoleInfoList, out error);
                bool bReturn = serviceBll.SetUserPwd(loggingSessionInfo, pNewPass, out error);
                res = "{\"success\":\"true\",\"msg\":\"" + error + "\"}";
            }
            else
            {
                res = "{\"success\":\"false\",\"msg\":\"旧密码不正确\"}";
            }
            return(res);
        }
示例#3
0
        protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetPasswordRP> pRequest)
        {
            //基础数据初始化
            string            error             = "";
            EmptyResponseData emptyResponseData = new EmptyResponseData();

            try
            {
                if (pRequest.Parameters.NewPassword.Length < 6)
                {
                    throw new APIException("新密码不小于6位。")
                          {
                              ErrorCode = ERROR_CODES.INVALID_BUSINESS
                          };
                }


                string newPassword = MD5Helper.Encryption(pRequest.Parameters.NewPassword);
                string oldPassword = EncryptManager.Hash(pRequest.Parameters.OldPassword, HashProviderType.MD5);

                //组装参数
                UserInfo entity     = new UserInfo();
                var      serviceBll = new cUserService(CurrentUserInfo);
                entity = serviceBll.GetUserById(CurrentUserInfo, CurrentUserInfo.UserID);
                string apPassword = serviceBll.GetPasswordFromAP(CurrentUserInfo.ClientID, CurrentUserInfo.UserID);

                if (oldPassword == apPassword)
                {
                    entity.userRoleInfoList = new cUserService(CurrentUserInfo).GetUserRoles(CurrentUserInfo.UserID, PageBase.JITPage.GetApplicationId());
                    entity.User_Password    = newPassword;
                    entity.ModifyPassword   = true;
                    //new cUserService(CurrentUserInfo).SetUserInfo(entity, entity.userRoleInfoList, out error);
                    bool bReturn = serviceBll.SetUserPwd(CurrentUserInfo, newPassword, out error);
                    if (!bReturn)
                    {
                        throw new APIException(error)
                              {
                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                              };
                    }
                }
                else
                {
                    throw new APIException("旧密码不正确")
                          {
                              ErrorCode = ERROR_CODES.INVALID_BUSINESS
                          };
                }
                return(emptyResponseData);
            }
            catch (APIException apiEx)
            {
                throw new APIException(apiEx.ErrorCode, apiEx.Message);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }