32 lines
960 B
C#
32 lines
960 B
C#
using MongoDB.Bson;
|
|
using MongoDB.Bson.Serialization.Attributes;
|
|
|
|
namespace Htmx.ApiDemo.Data;
|
|
|
|
/// <summary>
|
|
/// Simple user document stored in MongoDB.
|
|
/// All property→field name mappings are declared explicitly via [BsonElement]
|
|
/// and registered in Program.cs via BsonClassMap — no AutoMap() reflection.
|
|
/// </summary>
|
|
public sealed class AppUser
|
|
{
|
|
[BsonId]
|
|
public ObjectId Id { get; set; } = ObjectId.GenerateNewId();
|
|
|
|
[BsonElement("email")]
|
|
public string Email { get; set; } = "";
|
|
|
|
/// <summary>Email.ToUpperInvariant() — used for case-insensitive lookups.</summary>
|
|
[BsonElement("normalizedEmail")]
|
|
public string NormalizedEmail { get; set; } = "";
|
|
|
|
[BsonElement("passwordHash")]
|
|
public string PasswordHash { get; set; } = "";
|
|
|
|
[BsonElement("displayName")]
|
|
public string? DisplayName { get; set; }
|
|
|
|
[BsonElement("createdAtUtc")]
|
|
public DateTime CreatedAtUtc { get; set; } = DateTime.UtcNow;
|
|
}
|