public virtual bool CommunicationPassword(string communicationPassword) { bool returnValue = false; // 密码强度检查 if (SystemInfo.EnableCheckPasswordStrength && String.IsNullOrEmpty(communicationPassword)) { return(returnValue); } // 加密密码 if (SystemInfo.EnableEncryptServerPassword) { communicationPassword = this.EncryptUserPassword(communicationPassword); } // 判断输入原始密码是否正确 PiUserEntity userEntity = new PiUserEntity(); userEntity.GetFrom(this.GetDTById(UserInfo.Id)); //if (userEntity.CommunicationPassword == null) //{ // userEntity.CommunicationPassword = string.Empty; //} //if (userEntity.CommunicationPassword.Equals(communicationPassword)) //{ // returnValue = true; //} return(returnValue); }
/// <summary> /// 更新通讯密码 /// </summary> /// <param name="oldPassword">原密码</param> /// <param name="newPassword">新密码</param> /// <param name="statusCode">返回状态码</param> /// <returns>影响行数</returns> public virtual int ChangeCommunicationPassword(string oldPassword, string newPassword, out string statusCode) { #if (DEBUG) int milliStart = Environment.TickCount; #endif int returnValue = 0; // 密码强度检查 if (SystemInfo.EnableCheckPasswordStrength && String.IsNullOrEmpty(newPassword)) { statusCode = StatusCode.PasswordCanNotBeNull.ToString(); return(returnValue); } // 加密密码 if (SystemInfo.EnableEncryptServerPassword) { oldPassword = this.EncryptUserPassword(oldPassword); newPassword = this.EncryptUserPassword(newPassword); } // 判断输入原始密码是否正确 PiUserEntity userEntity = new PiUserEntity(); userEntity.GetFrom(this.GetDTById(UserInfo.Id)); //if (userEntity.CommunicationPassword == null) //{ // userEntity.CommunicationPassword = string.Empty; //} //// 密码错误 //if (!userEntity.CommunicationPassword.Equals(oldPassword)) //{ // statusCode = StatusCode.OldPasswordError.ToString(); // return returnValue; //} // 更改密码 // returnValue = this.SetProperty(UserInfo.Id, PiUserTable.FieldCommunicationPassword, newPassword); if (returnValue == 1) { statusCode = StatusCode.ChangePasswordOK.ToString(); } else { // 数据可能被删除 statusCode = StatusCode.ErrorDeleted.ToString(); } // 写入调试信息 #if (DEBUG) int milliEnd = Environment.TickCount; Trace.WriteLine(DateTime.Now.ToString(SystemInfo.TimeFormat) + " Ticks: " + TimeSpan.FromMilliseconds(milliEnd - milliStart).ToString() + " " + " BaseUserManager.ChangePassword(" + userEntity.Id + ")"); #endif return(returnValue); }