20220726 修改密码策略
This commit is contained in:
@@ -22,8 +22,7 @@ namespace BLL
|
||||
{
|
||||
var getUser = from x in db.SitePerson_Person
|
||||
where (x.Telephone == userInfo.Account || x.PersonName == userInfo.Account)
|
||||
&& (x.Password == Funs.EncryptionPassword(userInfo.Password)
|
||||
|| (x.IdentityCard != null && x.IdentityCard.Substring(x.IdentityCard.Length - 4) == userInfo.Password))
|
||||
&& x.Password == Funs.EncryptionPassword(userInfo.Password)
|
||||
&& x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime >= DateTime.Now) && x.IsUsed == true
|
||||
select new Model.UserItem
|
||||
{
|
||||
@@ -812,7 +811,8 @@ namespace BLL
|
||||
{
|
||||
newPerson.IsUsed = false;
|
||||
}
|
||||
newPerson.Password = PersonService.GetPersonPassWord(person.IdentityCard);
|
||||
newPerson.RawPassword = Funs.getInitialPassword(person.UnitId, person.IdentityCard);
|
||||
newPerson.Password = Funs.EncryptionPassword(newPerson.RawPassword);
|
||||
string rootUrl = ConfigurationManager.AppSettings["localRoot"];
|
||||
if (!string.IsNullOrEmpty(rootUrl) && !string.IsNullOrEmpty(person.PhotoUrl))
|
||||
{
|
||||
|
||||
+72
-1
@@ -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>
|
||||
|
||||
@@ -437,7 +437,8 @@ namespace BLL
|
||||
ProvinceCode = person.ProvinceCode,
|
||||
IsCardNoOK=IDCardValid.CheckIDCard(person.IdentityCard),
|
||||
};
|
||||
|
||||
newPerson.RawPassword = Funs.getInitialPassword(person.UnitId, person.IdentityCard);
|
||||
newPerson.Password = Funs.EncryptionPassword(newPerson.RawPassword);
|
||||
if (person.InTime.HasValue)
|
||||
{
|
||||
newPerson.InTime = person.InTime;
|
||||
@@ -532,11 +533,30 @@ namespace BLL
|
||||
newPerson.CountryCode = person.CountryCode;
|
||||
newPerson.ProvinceCode = person.ProvinceCode;
|
||||
newPerson.IsCardNoOK = IDCardValid.CheckIDCard(person.IdentityCard);
|
||||
|
||||
newPerson.RawPassword = Funs.getInitialPassword(person.UnitId, person.IdentityCard);
|
||||
newPerson.Password = Funs.EncryptionPassword(newPerson.RawPassword);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改密码
|
||||
/// </summary>
|
||||
/// <param name="personId"></param>
|
||||
/// <param name="password"></param>
|
||||
public static void UpdateSitePersonPassword(string personId, string password)
|
||||
{
|
||||
var m = Funs.DB.SitePerson_Person.FirstOrDefault(x => x.PersonId == personId);
|
||||
if (m != null)
|
||||
{
|
||||
m.RawPassword = password;
|
||||
m.Password = Funs.EncryptionPassword(password);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 人员离岗
|
||||
/// </summary>
|
||||
|
||||
@@ -176,12 +176,12 @@ namespace BLL
|
||||
/// <param name="password"></param>
|
||||
public static void UpdatePassword(string userId, string password)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.Sys_User m = db.Sys_User.FirstOrDefault(e => e.UserId == userId);
|
||||
Model.Sys_User m = Funs.DB.Sys_User.FirstOrDefault(e => e.UserId == userId);
|
||||
if (m != null)
|
||||
{
|
||||
m.RawPassword = password;
|
||||
m.Password = Funs.EncryptionPassword(password);
|
||||
db.SubmitChanges();
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,6 +199,7 @@ namespace BLL
|
||||
Account = user.Account,
|
||||
UserName = user.UserName,
|
||||
UserCode = user.UserCode,
|
||||
RawPassword = user.RawPassword,
|
||||
Password = user.Password,
|
||||
UnitId = user.UnitId,
|
||||
RoleId = user.RoleId,
|
||||
|
||||
Reference in New Issue
Block a user