[CHANGE] Implementing managers. repositories
This commit is contained in:
38
DotBased.AspNet.Authority/Models/AuthorityResult.cs
Normal file
38
DotBased.AspNet.Authority/Models/AuthorityResult.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using DotBased.AspNet.Authority.Models.Validation;
|
||||
|
||||
namespace DotBased.AspNet.Authority.Models;
|
||||
|
||||
public class AuthorityResult<TResultValue>
|
||||
{
|
||||
public AuthorityResult(bool success, string errorMessage = "", TResultValue? value = default, ResultFailReason reason = ResultFailReason.None, List<ValidationError>? errors = null)
|
||||
{
|
||||
Success = success;
|
||||
ErrorMessage = errorMessage;
|
||||
Value = value;
|
||||
Reason = reason;
|
||||
ValidationErrors = errors;
|
||||
}
|
||||
|
||||
public bool Success { get; }
|
||||
public string ErrorMessage { get; }
|
||||
public TResultValue? Value { get; }
|
||||
public ResultFailReason Reason { get; }
|
||||
public List<ValidationError>? ValidationErrors { get; }
|
||||
|
||||
|
||||
public static AuthorityResult<TResultValue> Ok(TResultValue? value) => new AuthorityResult<TResultValue>(true, value:value);
|
||||
|
||||
public static AuthorityResult<TResultValue> Error(string errorMessage, ResultFailReason reason = ResultFailReason.Error) =>
|
||||
new AuthorityResult<TResultValue>(false, errorMessage, reason:reason);
|
||||
|
||||
public static AuthorityResult<TResultValue> Failed(List<ValidationError> errors, ResultFailReason reason = ResultFailReason.None)
|
||||
=> new AuthorityResult<TResultValue>(false, errors:errors, reason:reason);
|
||||
}
|
||||
|
||||
public enum ResultFailReason
|
||||
{
|
||||
None,
|
||||
Unknown,
|
||||
Validation,
|
||||
Error
|
||||
}
|
7
DotBased.AspNet.Authority/Models/Options/ListOption.cs
Normal file
7
DotBased.AspNet.Authority/Models/Options/ListOption.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace DotBased.AspNet.Authority.Models.Options;
|
||||
|
||||
public enum ListOption
|
||||
{
|
||||
Blacklist,
|
||||
Whitelist
|
||||
}
|
@@ -4,7 +4,8 @@ public class UserOptions
|
||||
{
|
||||
public bool EnableRegister { get; set; }
|
||||
public bool RequireUniqueEmail { get; set; }
|
||||
public string AllowedCharacters { get; set; } = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@";
|
||||
public string UserNameCharacters { get; set; } = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@";
|
||||
public ListOption UserNameCharacterListType { get; set; } = ListOption.Whitelist;
|
||||
|
||||
public List<string> UserNameBlackList { get; set; } = ["admin", "administrator", "dev", "developer"];
|
||||
public StringComparer UserNameBlackListComparer { get; set; } = StringComparer.OrdinalIgnoreCase;
|
||||
|
Reference in New Issue
Block a user