feat: Add last_logout
column to users
table
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
parent
94e3e527ea
commit
7dab7e29cc
3 changed files with 13 additions and 3 deletions
|
@ -16,6 +16,7 @@
|
|||
|
||||
//! Functions for interacting with the user table in the database.
|
||||
|
||||
use chrono::Utc;
|
||||
use logcall::logcall;
|
||||
use oxidetalis_core::types::PublicKey;
|
||||
use oxidetalis_entities::prelude::*;
|
||||
|
@ -47,6 +48,7 @@ impl UserTableExt for DatabaseConnection {
|
|||
if let Err(err) = (UserActiveModel {
|
||||
public_key: Set(*public_key),
|
||||
is_admin: Set(is_admin),
|
||||
last_logout: Set(Utc::now()),
|
||||
..Default::default()
|
||||
})
|
||||
.save(self)
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
//! Entity for `users` table
|
||||
|
||||
use chrono::Utc;
|
||||
use oxidetalis_core::types::PublicKey;
|
||||
use sea_orm::entity::prelude::*;
|
||||
|
||||
|
@ -30,9 +31,10 @@ use crate::prelude::*;
|
|||
#[sea_orm(table_name = "users")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: UserId,
|
||||
pub public_key: PublicKey,
|
||||
pub is_admin: bool,
|
||||
pub id: UserId,
|
||||
pub public_key: PublicKey,
|
||||
pub last_logout: chrono::DateTime<Utc>,
|
||||
pub is_admin: bool,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
|
|
|
@ -47,6 +47,11 @@ impl MigrationTrait for Migration {
|
|||
.not_null()
|
||||
.unique_key(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Users::LastLogout)
|
||||
.timestamp_with_time_zone()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Users::IsAdmin)
|
||||
.boolean()
|
||||
|
@ -64,5 +69,6 @@ pub enum Users {
|
|||
Table,
|
||||
Id,
|
||||
PublicKey,
|
||||
LastLogout,
|
||||
IsAdmin,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue