Init commit

add security encryption and hashing: WIP
add endpoints: register user, get and save resources
add db main operations, User entity
This commit is contained in:
Alex Bezdieniezhnykh
2024-11-09 00:37:43 +02:00
commit 121052a3ef
26 changed files with 605 additions and 0 deletions
@@ -0,0 +1,17 @@
using Azaion.Common.Entities;
namespace Azaion.Common.Requests;
public class GetResourceRequest
{
public string Username { get; set; } = null!;
public string Password { get; set; } = null!;
public string HardwareId { get; set; } = null!;
public ResourceEnum ResourceEnum { get; set; }
}
public class UploadResourceRequest
{
public ResourceEnum ResourceEnum { get; set; }
public Stream Data { get; set; } = null!;
}
@@ -0,0 +1,22 @@
using FluentValidation;
namespace Azaion.Common.Requests;
public class RegisterUserRequest
{
public string Email { get; set; } = null!;
public string Password { get; set; } = null!;
public RoleEnum Role { get; set; }
}
public class RegisterUserValidator : AbstractValidator<RegisterUserRequest>
{
public RegisterUserValidator()
{
RuleFor(r => r.Email)
.MinimumLength(8).WithErrorCode(ExceptionEnum.UserLengthIncorrect.ToString()).WithMessage("Email address should be at least 8 characters.")
.EmailAddress().WithErrorCode(ExceptionEnum.WrongEmail.ToString()).WithMessage("Email address is not valid.");
RuleFor(r => r.Password)
.MinimumLength(8).WithErrorCode(ExceptionEnum.PasswordLengthIncorrect.ToString()).WithMessage("Password should be at least 8 characters.");
} }