Files
step3/api/QuestionsApi/Models/AuthModels.cs
T

135 lines
3.8 KiB
C#

using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace QuestionsApi.Models;
public sealed class AuthUser
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; } = default!;
public string Username { get; set; } = "";
public string PasswordHash { get; set; } = "";
public string Role { get; set; } = "USER";
public string? Email { get; set; }
public string? NormalizedEmail { get; set; }
public string? DisplayName { get; set; }
public DateTime? CreatedUtc { get; set; }
public string? RefreshToken { get; set; }
public DateTime? RefreshTokenExpiry { get; set; }
public string? SteamId { get; set; }
public int AuthVersion { get; set; }
public string? TermsAcceptedVersion { get; set; }
public string? PrivacyAcceptedVersion { get; set; }
public DateTime? LegalAcceptedUtc { get; set; }
public List<LegalAcceptanceRecord> LegalAcceptances { get; set; } = [];
}
public sealed class LegalAcceptanceRecord
{
public string TermsVersion { get; set; } = "";
public string PrivacyVersion { get; set; } = "";
public DateTime AcceptedUtc { get; set; } = DateTime.UtcNow;
public string Source { get; set; } = "";
}
public sealed class SteamAuthTransaction
{
[BsonId] public string Id { get; set; } = "";
public string Status { get; set; } = "pending";
public string? SteamId { get; set; }
public string? UserId { get; set; }
public DateTime CreatedUtc { get; set; }
public DateTime ExpiresUtc { get; set; }
}
public sealed class PasswordResetRequest
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; } = ObjectId.GenerateNewId().ToString();
public string UserId { get; set; } = "";
public string CodeHash { get; set; } = "";
public DateTime CreatedUtc { get; set; }
public DateTime ExpiresUtc { get; set; }
public int FailedAttempts { get; set; }
public DateTime? ConsumedUtc { get; set; }
}
public sealed class BlacklistedToken
{
[BsonId] public string Jti { get; set; } = "";
public DateTime ExpiresAt { get; set; }
}
public sealed class RegisterRequest
{
public string Username { get; set; } = "";
public string Password { get; set; } = "";
public string? Email { get; set; }
public bool AcceptLegal { get; set; }
}
public sealed class LoginRequest
{
public string Username { get; set; } = "";
public string Password { get; set; } = "";
}
public sealed class ChangeRoleRequest
{
public string Username { get; set; } = "";
public string NewRole { get; set; } = "";
}
public sealed class RefreshRequest
{
public string Username { get; set; } = "";
public string RefreshToken { get; set; } = "";
}
public sealed class UpdateAuthProfileRequest
{
public string? DisplayName { get; set; }
public string? Email { get; set; }
}
public sealed class ChangePasswordRequest
{
public string CurrentPassword { get; set; } = "";
public string NewPassword { get; set; } = "";
}
public sealed class DeleteAccountRequest
{
public string Password { get; set; } = "";
public string Confirmation { get; set; } = "";
}
public sealed class CompleteSteamRequest
{
public string TransactionId { get; set; } = "";
public string Action { get; set; } = "";
public string Username { get; set; } = "";
public string? Email { get; set; }
public string Password { get; set; } = "";
public bool AcceptLegal { get; set; }
}
public sealed class AcceptLegalRequest
{
public bool Accept { get; set; }
}
public sealed class PasswordResetStartRequest
{
public string Login { get; set; } = "";
}
public sealed class PasswordResetConfirmRequest
{
public string Login { get; set; } = "";
public string Code { get; set; } = "";
public string NewPassword { get; set; } = "";
}