From 35eee117d796bc60bb9512a6ddaa2567272d38c3 Mon Sep 17 00:00:00 2001 From: Ethan Girouard Date: Sun, 4 Feb 2024 17:34:45 -0500 Subject: [PATCH] Add PublicUser model --- src/models.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/models.rs b/src/models.rs index 2daf3ae..d93bc97 100644 --- a/src/models.rs +++ b/src/models.rs @@ -43,3 +43,20 @@ pub struct NewUser { /// The user's password, stored as a hash pub password: String, } + +/// Model for a "Public User", used for returning user data to the client +/// This model omits the password field, so that the hashed password is not sent to the client +#[cfg_attr(feature = "ssr", derive(Queryable, Selectable))] +#[cfg_attr(feature = "ssr", diesel(table_name = crate::schema::users))] +#[cfg_attr(feature = "ssr", diesel(check_for_backend(diesel::pg::Pg)))] +#[derive(Serialize, Deserialize)] +pub struct PublicUser { + /// A unique id for the user + pub id: i32, + /// The user's username + pub username: String, + /// The user's email + pub email: String, + /// The time the user was created + pub created_at: SystemTime, +}