[ADD] Implementing services/handlers

This commit is contained in:
max
2024-12-25 22:50:04 +01:00
parent 361af34036
commit ebfafa2f29
31 changed files with 360 additions and 44 deletions

View File

@@ -6,5 +6,6 @@ public class AuthorityOptions
public LockoutOptions Lockout { get; set; } = new();
public PasswordOptions Password { get; set; } = new();
public ProviderOptions Provider { get; set; } = new();
public RepositoryOptions Repository { get; set; } = new();
public UserOptions User { get; set; } = new();
}

View File

@@ -0,0 +1,10 @@
namespace DotBased.AspNet.Authority.Models.Options;
public class RepositoryOptions
{
/// <summary>
/// Use data encryption when a property has the <see cref="DotBased.AspNet.Authority.Attributes.ProtectAttribute"/> defined.
/// <value>Default: true</value>
/// </summary>
public bool UseDataProtection { get; set; } = true;
}

View File

@@ -0,0 +1,24 @@
namespace DotBased.AspNet.Authority.Models.Validation;
public class ValidationError
{
public ValidationError(string validator, string errorCode, string description)
{
Validator = validator;
ErrorCode = errorCode;
Description = description;
}
/// <summary>
/// The validator name that generated this error.
/// </summary>
public string Validator { get; }
/// <summary>
/// The error code
/// </summary>
public string ErrorCode { get; }
/// <summary>
/// Error description
/// </summary>
public string Description { get; }
}

View File

@@ -0,0 +1,21 @@
namespace DotBased.AspNet.Authority.Models.Validation;
public class ValidationResult
{
public ValidationResult(bool success, IEnumerable<ValidationError>? errors = null)
{
if (errors != null)
{
Errors = errors.ToList();
}
Success = success;
}
public bool Success { get; }
public IReadOnlyList<ValidationError> Errors { get; } = [];
public static ValidationResult Failed(IEnumerable<ValidationError> errors) => new(false, errors);
public static ValidationResult Ok() => new(true);
public override string ToString() => Success ? "Success" : $"Failed ({Errors.Count} errors)";
}