a06673b
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<crate::user::users::Entity>,
#[sea_orm(unique)]
pub token_hash: String,
pub user_agent_hash: Option<String>,
pub client_ip_hash: Option<String>,
#[sea_orm(default_value = "0")]
pub kind: SessionKind,
pub family_id: Uuid,
pub parent_refresh_id: Option<Uuid>,
#[sea_orm(default_value = "false")]
pub is_revoked: bool,
pub revoked_at: Option<OffsetDateTime>,
pub created_at: OffsetDateTime,
pub expires_at: OffsetDateTime,
pub replaced_at: Option<OffsetDateTime>,
pub grace_expires_at: Option<OffsetDateTime>,
pub updated_at: OffsetDateTime,
pub replaced_by: Option<Uuid>,
pub signing_key_id: Option<Uuid>,
pub app_id: Option<String>,
}
impl ActiveModelBehavior for ActiveModel {}