feat: Sistema de Usuarios - Backend CRUD + JWT Auth (Issue #1)
Implementación fundacional del proyecto PruebaGentle: - Arquitectura Clean/Hexagonal: Core, Infrastructure, API - 6 Stored Procedures para CRUD + autenticación - JWT authentication con BCrypt password hashing - Docker Compose (SQL Server + Backend) - Solución .NET 10 con Dapper + SqlClient Closes #1
This commit is contained in:
7
Backend/PruebaGentle.Core/Config/JwtSettings.cs
Normal file
7
Backend/PruebaGentle.Core/Config/JwtSettings.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace PruebaGentle.Core.Config;
|
||||
|
||||
public class JwtSettings
|
||||
{
|
||||
public string Secret { get; set; } = string.Empty;
|
||||
public int ExpirationHours { get; set; } = 24;
|
||||
}
|
||||
9
Backend/PruebaGentle.Core/DTOs/CreateUserDto.cs
Normal file
9
Backend/PruebaGentle.Core/DTOs/CreateUserDto.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace PruebaGentle.Core.DTOs;
|
||||
|
||||
public class CreateUserDto
|
||||
{
|
||||
public string Username { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string NombreCompleto { get; set; } = string.Empty;
|
||||
}
|
||||
7
Backend/PruebaGentle.Core/DTOs/LoginDto.cs
Normal file
7
Backend/PruebaGentle.Core/DTOs/LoginDto.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace PruebaGentle.Core.DTOs;
|
||||
|
||||
public class LoginDto
|
||||
{
|
||||
public string Username { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
7
Backend/PruebaGentle.Core/DTOs/LoginResponseDto.cs
Normal file
7
Backend/PruebaGentle.Core/DTOs/LoginResponseDto.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace PruebaGentle.Core.DTOs;
|
||||
|
||||
public class LoginResponseDto
|
||||
{
|
||||
public string Token { get; set; } = string.Empty;
|
||||
public DateTime ExpiresAt { get; set; }
|
||||
}
|
||||
8
Backend/PruebaGentle.Core/DTOs/UpdateUserDto.cs
Normal file
8
Backend/PruebaGentle.Core/DTOs/UpdateUserDto.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace PruebaGentle.Core.DTOs;
|
||||
|
||||
public class UpdateUserDto
|
||||
{
|
||||
public string Username { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string NombreCompleto { get; set; } = string.Empty;
|
||||
}
|
||||
10
Backend/PruebaGentle.Core/DTOs/UserResponseDto.cs
Normal file
10
Backend/PruebaGentle.Core/DTOs/UserResponseDto.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace PruebaGentle.Core.DTOs;
|
||||
|
||||
public class UserResponseDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Username { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string NombreCompleto { get; set; } = string.Empty;
|
||||
public DateTime FechaCreacion { get; set; }
|
||||
}
|
||||
11
Backend/PruebaGentle.Core/Entities/User.cs
Normal file
11
Backend/PruebaGentle.Core/Entities/User.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace PruebaGentle.Core.Entities;
|
||||
|
||||
public class User
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Username { get; set; } = string.Empty;
|
||||
public string PasswordHash { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string NombreCompleto { get; set; } = string.Empty;
|
||||
public DateTime FechaCreacion { get; set; }
|
||||
}
|
||||
7
Backend/PruebaGentle.Core/Interfaces/IPasswordHasher.cs
Normal file
7
Backend/PruebaGentle.Core/Interfaces/IPasswordHasher.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace PruebaGentle.Core.Interfaces;
|
||||
|
||||
public interface IPasswordHasher
|
||||
{
|
||||
string Hash(string password);
|
||||
bool Verify(string password, string hash);
|
||||
}
|
||||
13
Backend/PruebaGentle.Core/Interfaces/IUserRepository.cs
Normal file
13
Backend/PruebaGentle.Core/Interfaces/IUserRepository.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using PruebaGentle.Core.Entities;
|
||||
|
||||
namespace PruebaGentle.Core.Interfaces;
|
||||
|
||||
public interface IUserRepository
|
||||
{
|
||||
Task<User> CreateAsync(User user);
|
||||
Task<User?> GetByIdAsync(int id);
|
||||
Task<IEnumerable<User>> GetAllAsync();
|
||||
Task<User?> UpdateAsync(User user);
|
||||
Task<bool> DeleteAsync(int id);
|
||||
Task<User?> GetByUsernameAsync(string username);
|
||||
}
|
||||
9
Backend/PruebaGentle.Core/PruebaGentle.Core.csproj
Normal file
9
Backend/PruebaGentle.Core/PruebaGentle.Core.csproj
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user