use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; use time::OffsetDateTime; use uuid::Uuid; #[derive( Debug, Clone, Copy, PartialEq, Eq, Default, EnumIter, DeriveActiveEnum, Serialize, Deserialize, )] #[sea_orm(rs_type = "i16", db_type = "SmallInteger")] pub enum SessionKind { #[default] #[sea_orm(num_value = 0)] WebLogin, #[sea_orm(num_value = 1)] BearerAccess, } #[sea_orm::model] #[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[sea_orm(table_name = "user_session")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, pub user_id: Uuid, #[sea_orm(belongs_to, from = "user_id", to = "uid")] pub user: BelongsTo, #[sea_orm(unique)] pub token_hash: String, pub user_agent_hash: Option, pub client_ip_hash: Option, #[sea_orm(default_value = "0")] pub kind: SessionKind, pub family_id: Uuid, pub parent_refresh_id: Option, #[sea_orm(default_value = "false")] pub is_revoked: bool, pub revoked_at: Option, pub created_at: OffsetDateTime, pub expires_at: OffsetDateTime, pub replaced_at: Option, pub grace_expires_at: Option, pub updated_at: OffsetDateTime, pub replaced_by: Option, pub signing_key_id: Option, pub app_id: Option, } impl ActiveModelBehavior for ActiveModel {}