diff --git a/Cargo.lock b/Cargo.lock index 51a67ca..ef21df2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2193,6 +2193,7 @@ dependencies = [ "bitflags 1.3.2", "byteorder", "bytes", + "chrono", "crc", "crossbeam-queue", "dotenvy", @@ -2223,6 +2224,7 @@ dependencies = [ "sqlx-rt", "stringprep", "thiserror", + "time 0.3.21", "tokio-stream", "url", "webpki-roots", diff --git a/Cargo.toml b/Cargo.toml index f898e15..3109633 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ rocket = { version = "0.5.0-rc.3", features = ["secrets"]} rocket_dyn_templates = {version = "0.1.0-rc.3", features = [ "tera" ] } log = "0.4" env_logger = "0.10" -sqlx = { version = "0.6", features = ["sqlite", "runtime-tokio-rustls", "macros"] } +sqlx = { version = "0.6", features = ["sqlite", "runtime-tokio-rustls", "macros", "chrono", "time"] } argon2 = "0.5" serde = { version = "1.0", features = [ "derive" ]} serde_json = "1.0" diff --git a/src/model/user.rs b/src/model/user.rs index 0e5f8c2..97870b2 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -5,7 +5,7 @@ use rocket::{ async_trait, http::Status, request::{self, FromRequest, Outcome}, - Request, State, + Request, }; use serde::{Deserialize, Serialize}; use sqlx::{FromRow, SqlitePool}; @@ -20,6 +20,7 @@ pub struct User { pub is_guest: bool, #[serde(default = "bool::default")] deleted: bool, + pub last_access: Option, } #[derive(Debug)] @@ -37,7 +38,7 @@ impl User { sqlx::query_as!( User, " -SELECT id, name, pw, is_cox, is_admin, is_guest, deleted +SELECT id, name, pw, is_cox, is_admin, is_guest, deleted, last_access FROM user WHERE id like ? ", @@ -52,7 +53,7 @@ WHERE id like ? sqlx::query_as!( User, " -SELECT id, name, pw, is_cox, is_admin, is_guest, deleted +SELECT id, name, pw, is_cox, is_admin, is_guest, deleted, last_access FROM user WHERE name like ? ", @@ -67,7 +68,7 @@ WHERE name like ? sqlx::query_as!( User, " -SELECT id, name, pw, is_cox, is_admin, is_guest, deleted +SELECT id, name, pw, is_cox, is_admin, is_guest, deleted, last_access FROM user WHERE deleted = 0 ORDER BY name diff --git a/templates/admin/user/index.html.tera b/templates/admin/user/index.html.tera index 7f6f059..cfdd307 100644 --- a/templates/admin/user/index.html.tera +++ b/templates/admin/user/index.html.tera @@ -41,7 +41,11 @@
-
{{ user.name }}
+
{{ user.name }} + {% if user.last_access %} + (last access: {{ user.last_access | date }}) + {% endif %} +
{{ macros::checkbox(label='Gast', name='is_guest', id=loop.index , checked=user.is_guest) }} {{ macros::checkbox(label='Steuerberechtigter', name='is_cox', id=loop.index , checked=user.is_cox) }}