UserPasswordExpireVerify.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. namespace WingServerCommon.Interfaces.PasswordVerify
  2. {
  3. /// <summary>
  4. /// 用户密码验证管理类
  5. /// </summary>
  6. public class UserPasswordExpireVerify : PasswordExpireVerify
  7. {
  8. /// <summary>
  9. /// 用户密码验证有参构造
  10. /// </summary>
  11. public UserPasswordExpireVerify(Func<IList<string>, IList<PasswordVerifyModel>> loadDatasFunc, bool isOpen = true) : base(loadDatasFunc)
  12. {
  13. VerifyUserPasswordListen(1, isOpen);
  14. }
  15. /// <summary>
  16. /// 登录验证密码是否有效
  17. /// </summary>
  18. /// <param name="tokenList">用户数据</param>
  19. /// <returns>验证结果</returns>
  20. public VerifyBaseModel VerifyPasswordExpire(PasswordVerifyModel query)
  21. {
  22. var verifyResult = new VerifyBaseModel();
  23. if (query.PasswordLastUpdateTime < Convert.ToDateTime("2000-1-1"))
  24. {
  25. return verifyResult;
  26. }
  27. verifyResult = VerifyData(query.ClientId, query.PasswordLastUpdateTime);
  28. return verifyResult;
  29. }
  30. /// <summary>
  31. /// 修改密码,验证是否重复
  32. /// </summary>
  33. /// <param name="request">修改请求数据</param>
  34. /// <returns>是否成功</returns>
  35. public bool VerifySamePassword(PasswordVerifyModel request)
  36. {
  37. var result = false;
  38. //验证密码是否重复
  39. if (request.PasswordRecords != null && request.PasswordRecords.Count > 0 &&
  40. !request.PasswordRecords.Contains(request.NewPassword))
  41. {
  42. //没有
  43. result = true;
  44. }
  45. else if (request.PasswordRecords != null && request.PasswordRecords.Count == 0)
  46. {
  47. //没有
  48. result = true;
  49. }
  50. return result;
  51. }
  52. }
  53. }