mirror of
https://github.com/hmaxnl/DotBased.git
synced 2025-04-05 22:11:27 +02:00
[CHANGE] Update errors to IReadOnlyList
This commit is contained in:
parent
c6e11efdf2
commit
79d8fcfb8d
|
@ -45,9 +45,7 @@ public partial class AuthorityManager
|
||||||
var passwordValidation = await ValidatePasswordAsync(user, password);
|
var passwordValidation = await ValidatePasswordAsync(user, password);
|
||||||
if (!passwordValidation.Success)
|
if (!passwordValidation.Success)
|
||||||
{
|
{
|
||||||
List<ValidationError> errors = [];
|
return AuthorityResult<AuthorityUser>.Failed(passwordValidation.Errors, ResultFailReason.Validation);
|
||||||
errors.AddRange(passwordValidation.Errors);
|
|
||||||
return AuthorityResult<AuthorityUser>.Failed(errors, ResultFailReason.Validation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
user.PasswordHash = await PasswordHasher.HashPasswordAsync(password);
|
user.PasswordHash = await PasswordHasher.HashPasswordAsync(password);
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class AuthorityResult<TResultValue> : Result<TResultValue>
|
||||||
Reason = ResultFailReason.Unknown;
|
Reason = ResultFailReason.Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthorityResult(bool success, string errorMessage = "", TResultValue? value = default, ResultFailReason reason = ResultFailReason.None, List<ValidationError>? errors = null) : base(success, errorMessage, value, null)
|
public AuthorityResult(bool success, string errorMessage = "", TResultValue? value = default, ResultFailReason reason = ResultFailReason.None, IReadOnlyList<ValidationError>? errors = null) : base(success, errorMessage, value, null)
|
||||||
{
|
{
|
||||||
Success = success;
|
Success = success;
|
||||||
Message = errorMessage;
|
Message = errorMessage;
|
||||||
|
@ -20,7 +20,7 @@ public class AuthorityResult<TResultValue> : Result<TResultValue>
|
||||||
ValidationErrors = errors;
|
ValidationErrors = errors;
|
||||||
}
|
}
|
||||||
public ResultFailReason Reason { get; }
|
public ResultFailReason Reason { get; }
|
||||||
public List<ValidationError>? ValidationErrors { get; }
|
public IReadOnlyList<ValidationError>? ValidationErrors { get; }
|
||||||
|
|
||||||
|
|
||||||
public static AuthorityResult<TResultValue> Ok(TResultValue? value) => new AuthorityResult<TResultValue>(true, value:value);
|
public static AuthorityResult<TResultValue> Ok(TResultValue? value) => new AuthorityResult<TResultValue>(true, value:value);
|
||||||
|
@ -28,7 +28,7 @@ public class AuthorityResult<TResultValue> : Result<TResultValue>
|
||||||
public static AuthorityResult<TResultValue> Error(string errorMessage, ResultFailReason reason = ResultFailReason.Error) =>
|
public static AuthorityResult<TResultValue> Error(string errorMessage, ResultFailReason reason = ResultFailReason.Error) =>
|
||||||
new AuthorityResult<TResultValue>(false, errorMessage, reason:reason);
|
new AuthorityResult<TResultValue>(false, errorMessage, reason:reason);
|
||||||
|
|
||||||
public static AuthorityResult<TResultValue> Failed(List<ValidationError> errors, ResultFailReason reason = ResultFailReason.None)
|
public static AuthorityResult<TResultValue> Failed(IReadOnlyList<ValidationError> errors, ResultFailReason reason = ResultFailReason.None)
|
||||||
=> new AuthorityResult<TResultValue>(false, errors:errors, reason:reason);
|
=> new AuthorityResult<TResultValue>(false, errors:errors, reason:reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user