Files
NTBug/web/Helpdesk.Web/Api/ApiModels.cs
T
PatTheEvil d3a1b1cb17 web: přihlášení přes API a automatická obnova tokenů
Typovaný klient REST API, tokeny v šifrované HttpOnly cookie, obnova access
tokenu před vypršením se sloučením souběžných obnov (ochrana proti
REUSE_DETECTED), odhlášení a společné zpracování chyb API.

Refs #21
2026-12-02 00:26:42 +01:00

48 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
namespace Helpdesk.Web.Api;
// Kontrakt REST API /api/v1 tak, jak ho web používá. Web je tenký klient a na projekty
// backendu nemá referenci – DTO jsou zde zrcadlem dokumentace ve Swaggeru.
public sealed record UserDto(
int Id,
string Email,
string FirstName,
string LastName,
string? Phone,
string Role,
bool EmailNotificationsEnabled)
{
public string FullName => $"{FirstName} {LastName}";
}
public sealed record AuthResponse(
string AccessToken,
DateTimeOffset AccessTokenExpiresAt,
string RefreshToken,
DateTimeOffset RefreshTokenExpiresAt,
UserDto User)
{
public TokenSet Tokens => new(AccessToken, AccessTokenExpiresAt, RefreshToken, RefreshTokenExpiresAt);
}
/// <summary>Pár tokenů uložený v autentizační cookie webu.</summary>
public sealed record TokenSet(
string AccessToken,
DateTimeOffset AccessTokenExpiresAt,
string RefreshToken,
DateTimeOffset RefreshTokenExpiresAt);
public sealed record LoginRequest(string Email, string Password);
public sealed record RegisterRequest(string Email, string Password, string FirstName, string LastName);
public sealed record RefreshTokenRequest(string RefreshToken);
public sealed record EmailTokenRequest(string Token);
public sealed record ForgotPasswordRequest(string Email);
public sealed record ResetPasswordRequest(string Token, string NewPassword);
public sealed record UpdateProfileRequest(string FirstName, string LastName, string? Phone, bool EmailNotificationsEnabled);