コード例 #1
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var result = ValidationResult.Success;

            if (value != null)
            {
                var userId =
                    validationContext.ObjectType.GetProperty(OtherPropertyName).GetValue(validationContext.ObjectInstance, null);

                if (PasswordHistoryService.IsPasswordInHistory(userId.ToString(), value.ToString()))
                {
                    result = new ValidationResult("This password has already been used recently, please choose another password");
                }
            }

            return(result);
        }
コード例 #2
0
 public void SetUp()
 {
     this.passwordHistoryRepository = new Mock <IPasswordHistoryRepository>();
     this.passwordHistoryService    = new PasswordHistoryService(this.passwordHistoryRepository.Object);
 }