Základní backend: migrace, autentizace JWT, role, Swagger
- Helpdesk.Migrator (DbUp) aplikuje db/migrations, evidence v schema_version - Domain/Application/Infrastructure/Api podle Clean Architecture - registrace, ověření e-mailu, login, refresh s rotací, logout, reset hesla - JWT podle RFC 7519 evidované jen podle jti v auth_token - správa uživatelů a rolí, číselníky, ProblemDetails, Swagger UI - Docker Compose (db, migrator, api), oddělené DB účty - notifikace mají cizí klíče na issue a proposal - unit testy domény a zabezpečení Closes #1, closes #2, closes #3, closes #4, closes #5, closes #9
This commit is contained in:
1 parent
fc76be7d69
commit
a51d386278
64 files changed
+4394
-1
No files matched your search
@@ -0,0 +1,47 @@
|
||||
using FluentValidation;
|
||||
using Helpdesk.Domain;
|
||||
using Helpdesk.Domain.Users;
|
||||
|
||||
namespace Helpdesk.Application.Users;
|
||||
|
||||
/// <summary>Profil uživatele. Role se vrací jako kód (<c>STUDENT</c>, <c>FACILITY_MANAGER</c>, …).</summary>
|
||||
public sealed record UserDto(
|
||||
int Id,
|
||||
string Email,
|
||||
string FirstName,
|
||||
string LastName,
|
||||
string? Phone,
|
||||
string Role,
|
||||
bool EmailNotificationsEnabled)
|
||||
{
|
||||
public static UserDto From(User user) => new(
|
||||
user.Id, user.Email, user.FirstName, user.LastName, user.Phone, user.Role.ToCode(), user.EmailNotificationsEnabled);
|
||||
}
|
||||
|
||||
public sealed record UpdateProfileRequest(string FirstName, string LastName, string? Phone, bool EmailNotificationsEnabled);
|
||||
|
||||
public sealed class UpdateProfileRequestValidator : AbstractValidator<UpdateProfileRequest>
|
||||
{
|
||||
public UpdateProfileRequestValidator()
|
||||
{
|
||||
RuleFor(x => x.FirstName).NotEmpty().MaximumLength(100);
|
||||
RuleFor(x => x.LastName).NotEmpty().MaximumLength(100);
|
||||
RuleFor(x => x.Phone).MaximumLength(30).Matches(@"^\+?[0-9 ]+$").When(x => !string.IsNullOrWhiteSpace(x.Phone))
|
||||
.WithMessage("Telefon smí obsahovat jen číslice, mezery a úvodní +.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Uživatel v přehledu administrátora.</summary>
|
||||
public sealed record AdminUserDto(
|
||||
int Id,
|
||||
string Email,
|
||||
string FirstName,
|
||||
string LastName,
|
||||
string Role,
|
||||
bool IsActive,
|
||||
bool EmailConfirmed,
|
||||
DateTime CreatedAt);
|
||||
|
||||
public sealed record ChangeRoleRequest(string Role);
|
||||
|
||||
public sealed record SetActiveRequest(bool IsActive);
|
||||
Reference in new issue
Block a user