user.rs
60 lignes · 2479 octets
use chrono::{DateTime, Utc}; use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; use uuid::Uuid; /// User entity model /// /// Represents a user in the RustWarden system. /// Users can have multiple roles through the many-to-many relationship. #[derive(Clone, Debug, Serialize, Deserialize, DeriveEntityModel)] #[sea_orm(table_name = "users")] pub struct Model { /// Unique identifier for the user #[sea_orm(primary_key)] pub id: Uuid, /// Username (unique, 3-64 characters) #[sea_orm(unique)] pub username: String, /// Email address (unique, max 255 characters) #[sea_orm(unique)] pub email: String, /// Hashed password (bcrypt, max 255 characters) pub password_hash: String, /// Flag indicating if the user must change password on next login pub must_change_password: bool, /// Last login timestamp (nullable) pub last_login_at: Option<DateTime<Utc>>, /// Last login IP address (nullable, supports IPv4/IPv6) pub last_login_ip: Option<String>, /// Password last changed timestamp (nullable, for expiration tracking) pub password_changed_at: Option<DateTime<Utc>>, /// Email verified flag (default: false for new users) pub email_verified: bool, /// Email verification timestamp (nullable, set when email is verified) pub email_verified_at: Option<DateTime<Utc>>, /// Creation timestamp pub created_at: DateTime<Utc>, /// Last update timestamp pub updated_at: DateTime<Utc>, /// ActivityPub public key PEM (SPKI). `None` until first AP resolution. /// /// Populated lazily by `ActorKeyService::ensure_keys` (RFC 0005). The /// column is added by migration /// `m20260510_000009_fediverse_interop`. pub ap_public_key_pem: Option<String>, /// ActivityPub private key PEM (PKCS#8), encrypted at rest via /// `CryptoService` (`enc:` prefix + AES-256-GCM). Never returned in /// clear except by `ActorKeyService::ensure_keys` to its caller. pub ap_private_key_pem: Option<String>, /// Whether this user wants to be discoverable by remote fediverse /// search. Defaults to `true`. Read by NodeInfo and (later) by /// fediverse search endpoints. pub ap_discoverable: bool, } /// SeaORM relations for the User entity (none defined here; relations are declared on child entities). #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation {} impl ActiveModelBehavior for ActiveModel {}
GitRust