Add JWT authentication with AuthController and services

This commit is contained in:
Denis Urs Rudolph
2026-04-03 21:00:16 +02:00
parent 8bfd49e0ab
commit b6962e1024
6 changed files with 224 additions and 12 deletions
+45
View File
@@ -0,0 +1,45 @@
using System.ComponentModel.DataAnnotations;
using RacePlannerApi.Models;
namespace RacePlannerApi.DTOs;
public class RegisterRequest
{
[Required]
[EmailAddress]
public string Email { get; set; } = string.Empty;
[Required]
[MinLength(8)]
public string Password { get; set; } = string.Empty;
[Required]
[MinLength(2)]
public string Name { get; set; } = string.Empty;
public UserRole Role { get; set; } = UserRole.Participant;
}
public class LoginRequest
{
[Required]
[EmailAddress]
public string Email { get; set; } = string.Empty;
[Required]
public string Password { get; set; } = string.Empty;
}
public class AuthResponse
{
public string Token { get; set; } = string.Empty;
public UserDto User { get; set; } = null!;
}
public class UserDto
{
public Guid Id { get; set; }
public string Email { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public string Role { get; set; } = string.Empty;
}