From 3ca9211e5d91efd63e7dc5f30fbe08b109f1c839 Mon Sep 17 00:00:00 2001 From: pjht Date: Fri, 18 Oct 2024 19:56:54 -0500 Subject: [PATCH] Redact password hashes in debug output --- server/src/models.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/server/src/models.rs b/server/src/models.rs index c2c557b..49fc8e3 100644 --- a/server/src/models.rs +++ b/server/src/models.rs @@ -1,8 +1,10 @@ +use std::fmt::Debug; + use crate::schema::*; use chrono::{DateTime, Local}; use diesel::prelude::*; -#[derive(Queryable, Selectable, Debug, Clone)] +#[derive(Queryable, Selectable, Clone)] #[diesel(table_name = users)] #[diesel(check_for_backend(diesel::sqlite::Sqlite))] pub struct User { @@ -12,6 +14,17 @@ pub struct User { pub display_name: String, } +impl Debug for User { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("User") + .field("id", &self.id) + .field("username", &self.username) + .field("pw_hash", &"") + .field("display_name", &self.display_name) + .finish() + } +} + #[derive(Insertable)] #[diesel(table_name = users)] pub struct NewUser<'a> {