- La sesión caduca tras un tiempo sin uso, no desde el login, y se
prorroga como mucho cada `write_interval_secs`; la cookie de
"recordarme" se renueva con ella.
- Nueva subsección `[user.session]` con `cookie_name` ("pagetop"),
`secure_cookie`, `idle_secs`, `remember_idle_secs` y
`write_interval_secs`.
33 lines
810 B
Rust
33 lines
810 B
Rust
use pagetop_seaorm::db::*;
|
|
|
|
#[derive(Clone, Debug, DeriveEntityModel, PartialEq)]
|
|
#[sea_orm(table_name = "sessions")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false)]
|
|
pub sid: String,
|
|
pub user_id: i32,
|
|
pub data: String,
|
|
pub remember: bool,
|
|
pub last_activity_at: Option<DateTimeUtc>,
|
|
pub expires_at: DateTimeUtc,
|
|
pub created_at: DateTimeUtc,
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, DeriveRelation, EnumIter)]
|
|
pub enum Relation {
|
|
#[sea_orm(
|
|
belongs_to = "super::user::Entity",
|
|
from = "Column::UserId",
|
|
to = "super::user::Column::Id",
|
|
on_delete = "Cascade"
|
|
)]
|
|
User,
|
|
}
|
|
|
|
impl Related<super::user::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::User.def()
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|