Fixes
This commit is contained in:
@@ -5,6 +5,5 @@ namespace AipsCore.Domain.Models.User.External;
|
||||
|
||||
public interface IUserRepository : IAbstractRepository<User, UserId>
|
||||
{
|
||||
Task SignUpWithPasswordAsync(User user, string password, CancellationToken cancellationToken = default);
|
||||
Task<LoginResult> LoginWithEmailAndPasswordAsync(string email, string password, CancellationToken cancellationToken = default);
|
||||
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
namespace AipsCore.Domain.Models.User.External;
|
||||
|
||||
public record LoginResult(User User, IList<string> Roles);
|
||||
@@ -17,10 +17,8 @@ public record UserRole
|
||||
|
||||
public static IEnumerable<UserRole> All() => [User, Admin];
|
||||
|
||||
public static UserRole FromString(string name)
|
||||
public static UserRole? FromString(string name)
|
||||
{
|
||||
var role = All().FirstOrDefault(r => r.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
return role ?? throw new ValidationException(UserErrors.RoleDoesNotExist(name));
|
||||
return All().FirstOrDefault(r => r.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace AipsCore.Domain.Models.User.Options;
|
||||
|
||||
public static partial class UserOptionsDefaults
|
||||
{
|
||||
public const int PasswordRequiredLength = 8;
|
||||
public const bool PasswordRequireDigit = true;
|
||||
public const bool PasswordRequireLowercase = true;
|
||||
public const bool PasswordRequireUppercase = true;
|
||||
public const bool PasswordRequireNonAlphanumeric = true;
|
||||
|
||||
public const bool UserRequireUniqueEmail = true;
|
||||
}
|
||||
@@ -7,18 +7,10 @@ namespace AipsCore.Domain.Models.User.Validation;
|
||||
|
||||
public class UserErrors : AbstractErrors<User, UserId>
|
||||
{
|
||||
public static ValidationError LoginErrorUserNotFoundByEmail(string email)
|
||||
public static ValidationError InvalidCredentials()
|
||||
{
|
||||
string code = "login_error_user_not_found_by_email";
|
||||
string message = $"User with email '{email}' not found";
|
||||
|
||||
return CreateValidationError(code, message);
|
||||
}
|
||||
|
||||
public static ValidationError LoginErrorIncorrectPassword()
|
||||
{
|
||||
string code = "login_error_incorrect_password";
|
||||
string message = $"Incorrect password provided";
|
||||
string code = "invalid_credentials";
|
||||
string message = "Invalid credentials";
|
||||
|
||||
return CreateValidationError(code, message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user