Redact password hashes in debug output

This commit is contained in:
pjht 2024-10-18 19:56:54 -05:00
parent 35a68e46f7
commit 3ca9211e5d
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E

View File

@ -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", &"<redacted>")
.field("display_name", &self.display_name)
.finish()
}
}
#[derive(Insertable)]
#[diesel(table_name = users)]
pub struct NewUser<'a> {