20230806修改账号的密码安全策略

This commit is contained in:
2023-08-06 22:38:05 +08:00
parent f13d77c520
commit 2804d7c4df
15 changed files with 189 additions and 174 deletions
+5 -1
View File
@@ -114,9 +114,13 @@ namespace BLL
PersonName = item.UserName,
IdentityCard = item.IdentityCard,
UnitId = Const.UnitId_SEDIN,
Password = Funs.EncryptionPassword(Const.Password),
DataFrom = "API"
};
newPersons.RawPassword = Funs.getInitialPassword(newPersons.UnitId, newPersons.IdentityCard);
newPersons.Password = Funs.EncryptionPassword(newPersons.RawPassword);
if (item.Image != "")
{
string rootUrl = ConfigurationManager.AppSettings["localRoot"];
+12 -24
View File
@@ -64,9 +64,6 @@
<HintPath>..\FineUIPro\Reference BLL\Interop.WIA.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.2.1.1\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
@@ -107,8 +104,8 @@
<Reference Include="QRCoder, Version=1.4.3.0, Culture=neutral, PublicKeyToken=c4ed5b9ae8358a28, processorArchitecture=MSIL">
<HintPath>..\packages\QRCoder.1.4.3\lib\net40\QRCoder.dll</HintPath>
</Reference>
<Reference Include="Quartz, Version=3.5.0.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
<HintPath>..\packages\Quartz.3.5.0\lib\netstandard2.0\Quartz.dll</HintPath>
<Reference Include="Quartz, Version=3.7.0.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
<HintPath>..\packages\Quartz.3.7.0\lib\netstandard2.0\Quartz.dll</HintPath>
</Reference>
<Reference Include="RestSharp, Version=106.15.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.106.15.0\lib\net452\RestSharp.dll</HintPath>
@@ -118,8 +115,8 @@
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.configuration" />
<Reference Include="System.Configuration.ConfigurationManager, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Configuration.ConfigurationManager.4.7.0\lib\net461\System.Configuration.ConfigurationManager.dll</HintPath>
<Reference Include="System.Configuration.ConfigurationManager, Version=6.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Configuration.ConfigurationManager.6.0.1\lib\net461\System.Configuration.ConfigurationManager.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Data.Linq" />
@@ -141,28 +138,22 @@
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
<Reference Include="System.Security.AccessControl, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.AccessControl.4.7.0\lib\net461\System.Security.AccessControl.dll</HintPath>
<Reference Include="System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.AccessControl.6.0.0\lib\net461\System.Security.AccessControl.dll</HintPath>
</Reference>
<Reference Include="System.Security.Permissions, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Permissions.4.7.0\lib\net461\System.Security.Permissions.dll</HintPath>
<Reference Include="System.Security.Permissions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Permissions.6.0.0\lib\net461\System.Security.Permissions.dll</HintPath>
</Reference>
<Reference Include="System.Security.Principal.Windows, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Principal.Windows.4.7.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
<Reference Include="System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
</Reference>
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Text.Encodings.Web, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.5.0.0\lib\net461\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.5.0.0\lib\net461\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
@@ -184,9 +175,6 @@
<HintPath>..\FineUIPro\Reference BLL\ThoughtWorks.QRCode.Fakes.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="ZKWeb.System.Drawing, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ZKWeb.System.Drawing.4.0.0\lib\net45\ZKWeb.System.Drawing.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="API\APIBaseInfoService.cs" />
+1 -1
View File
@@ -48,7 +48,7 @@ namespace BLL
/// <summary>
/// 默认用户密码
/// </summary>
public const string Password = "123";
// public const string Password = "123";
/// <summary>
/// 默认用户密码
+70
View File
@@ -165,6 +165,76 @@ namespace BLL
//return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
}
#region
/// <summary>
/// 获取用户初始密码
/// </summary>
/// <param name="password"></param>
/// <returns></returns>
public static string getInitialPassword(string unitId, string idCard)
{
string prefixValue = "sedin";
string suffixValue = "1234";
//var getUnit = UnitService.GetUnitByUnitId(unitId);
//if (getUnit != null)
//{
// if (!string.IsNullOrEmpty(getUnit.UnitCode))
// {
// if (getUnit.UnitCode.Length > 10)
// {
// prefixValue = getUnit.UnitCode.Substring(getUnit.UnitCode.Length - 10);
// }
// else
// {
// prefixValue = getUnit.UnitCode;
// }
// }
//}
if (!string.IsNullOrEmpty(idCard))
{
if (idCard.Length > 4)
{
suffixValue = idCard.Substring(idCard.Length - 4);
}
else
{
suffixValue = idCard;
}
}
return prefixValue + "." + suffixValue;
}
#endregion
#region
/// <summary>
///
/// </summary>
/// <param name="c"></param>
/// <returns></returns>
public static bool IsLetter(char c)
{
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
}
public static bool IsDigit(char c)
{
return c >= '0' && c <= '9';
}
static bool IsSymbol(char c)
{
return c > 32 && c < 127 && !IsDigit(c) && !IsLetter(c);
}
public static bool IsValIDPassword(string password)
{
return
password.Any(c => IsLetter(c)) &&
password.Any(c => IsDigit(c)) &&
password.Any(c => IsSymbol(c));
}
#endregion
/// <summary>
/// 为目标下拉框加上 "请选择" 项
/// </summary>
+11 -33
View File
@@ -667,6 +667,7 @@ namespace BLL
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
string password = Funs.getInitialPassword(person.UnitId, person.IdentityCard);
Model.Person_Persons newPerson = new Model.Person_Persons
{
PersonId = person.PersonId,
@@ -676,7 +677,8 @@ namespace BLL
JobNum = person.JobNum,
PersonName = person.PersonName,
Account = person.Account,
Password = GetPersonPassWord(person.IdentityCard, person.Account),
RawPassword = password,
Password =Funs.EncryptionPassword(password),
IsOffice = person.IsOffice,
RoleIds = person.RoleIds,
IdentityCard = person.IdentityCard,
@@ -877,7 +879,6 @@ namespace BLL
table.JobNum = newtable.JobNum;
table.PersonName = newtable.PersonName;
table.Account = newtable.Account;
table.Password = newtable.Password;
table.IsOffice = newtable.IsOffice;
table.RoleIds = newtable.RoleIds;
table.IdentityCard = newtable.IdentityCard;
@@ -1107,32 +1108,6 @@ namespace BLL
}
#region
/// <summary>
/// 设置人员密码
/// </summary>
/// <param name="idCard"></param>
/// <returns></returns>
public static string GetPersonPassWord(string idCard,string Account)
{
string passWord = Funs.EncryptionPassword(Const.Password);
if (string.IsNullOrEmpty(Account))
{
////现场人员密码
if (!string.IsNullOrEmpty(idCard))
{
if (idCard.Length > 3)
{
passWord = Funs.EncryptionPassword(idCard.Substring(idCard.Length - 4));
}
else
{
passWord = Funs.EncryptionPassword(idCard);
}
}
}
return passWord;
}
/// <summary>
/// 修改密码
/// </summary>
@@ -1140,12 +1115,15 @@ namespace BLL
/// <param name="password"></param>
public static void UpdatePassword(string personId, string password)
{
Model.SGGLDB db = Funs.DB;
Model.Person_Persons m = db.Person_Persons.FirstOrDefault(e => e.PersonId == personId);
if (m != null)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
m.Password = Funs.EncryptionPassword(password);
db.SubmitChanges();
var m = db.Person_Persons.FirstOrDefault(e => e.PersonId == personId);
if (m != null)
{
m.RawPassword = password;
m.Password = Funs.EncryptionPassword(password);
db.SubmitChanges();
}
}
}
#endregion