Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2024-11-16 04:12:53 +01:00
Merge pull request #1245 from janost/user-last-login
Show last active it on admin users page
Dieser Commit ist enthalten in:
Commit
db710bb931
4 geänderte Dateien mit 25 neuen und 0 gelöschten Zeilen
|
@ -297,6 +297,11 @@ fn users_overview(_token: AdminToken, conn: DbConn) -> ApiResult<Html<String>> {
|
||||||
usr["cipher_count"] = json!(Cipher::count_owned_by_user(&u.uuid, &conn));
|
usr["cipher_count"] = json!(Cipher::count_owned_by_user(&u.uuid, &conn));
|
||||||
usr["attachment_count"] = json!(Attachment::count_by_user(&u.uuid, &conn));
|
usr["attachment_count"] = json!(Attachment::count_by_user(&u.uuid, &conn));
|
||||||
usr["attachment_size"] = json!(get_display_size(Attachment::size_by_user(&u.uuid, &conn) as i32));
|
usr["attachment_size"] = json!(get_display_size(Attachment::size_by_user(&u.uuid, &conn) as i32));
|
||||||
|
usr["created_at"] = json!(&u.created_at.format("%Y-%m-%d %H:%M:%S").to_string());
|
||||||
|
usr["last_active"] = match u.last_active(&conn) {
|
||||||
|
Some(timestamp) => json!(timestamp.format("%Y-%m-%d %H:%M:%S").to_string()),
|
||||||
|
None => json!("Never")
|
||||||
|
};
|
||||||
usr
|
usr
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
|
|
|
@ -178,4 +178,15 @@ impl Device {
|
||||||
.from_db()
|
.from_db()
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn find_latest_active_by_user(user_uuid: &str, conn: &DbConn) -> Option<Self> {
|
||||||
|
db_run! { conn: {
|
||||||
|
devices::table
|
||||||
|
.filter(devices::user_uuid.eq(user_uuid))
|
||||||
|
.order(devices::updated_at.desc())
|
||||||
|
.first::<DeviceDb>(conn)
|
||||||
|
.ok()
|
||||||
|
.from_db()
|
||||||
|
}}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -288,6 +288,13 @@ impl User {
|
||||||
users::table.load::<UserDb>(conn).expect("Error loading users").from_db()
|
users::table.load::<UserDb>(conn).expect("Error loading users").from_db()
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn last_active(&self, conn: &DbConn) -> Option<NaiveDateTime> {
|
||||||
|
match Device::find_latest_active_by_user(&self.uuid, conn) {
|
||||||
|
Some(device) => Some(device.updated_at),
|
||||||
|
None => None
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Invitation {
|
impl Invitation {
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
<div class="float-left">
|
<div class="float-left">
|
||||||
<strong>{{Name}}</strong>
|
<strong>{{Name}}</strong>
|
||||||
<span class="d-block">{{Email}}</span>
|
<span class="d-block">{{Email}}</span>
|
||||||
|
<span class="d-block">Created at: {{created_at}}</span>
|
||||||
|
<span class="d-block">Last active: {{last_active}}</span>
|
||||||
<span class="d-block">
|
<span class="d-block">
|
||||||
{{#if TwoFactorEnabled}}
|
{{#if TwoFactorEnabled}}
|
||||||
<span class="badge badge-success mr-2" title="2FA is enabled">2FA</span>
|
<span class="badge badge-success mr-2" title="2FA is enabled">2FA</span>
|
||||||
|
|
Laden …
In neuem Issue referenzieren