20220726 修改密码策略

This commit is contained in:
2022-07-26 13:51:21 +08:00
parent 0f7638febc
commit 31efa1eac9
13 changed files with 277 additions and 57 deletions
+72 -1
View File
@@ -4,8 +4,8 @@ namespace BLL
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Linq;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
@@ -146,6 +146,7 @@ namespace BLL
//}
private static object locker = new object();
/// <summary>
/// 数据库上下文。
/// </summary>
@@ -195,6 +196,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 = "CWCEC";
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>